X Tutup
The Wayback Machine - https://web.archive.org/web/20201126082027/https://github.com/koding/kite/issues/197
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: state explicitly what is required to use Kontrol API #197

Open
HolaYang opened this issue Mar 21, 2017 · 6 comments
Open

examples: state explicitly what is required to use Kontrol API #197

HolaYang opened this issue Mar 21, 2017 · 6 comments
Labels

Comments

@HolaYang
Copy link

@HolaYang HolaYang commented Mar 21, 2017

I do every process in tutorial.

But it raises "No kontrol URL given in config"

What should I do to figure it out?

@rjeczalik
Copy link
Member

@rjeczalik rjeczalik commented Mar 21, 2017

@Takeoffyoung In order to use Kontrol API you need to configure its endpoint first, e.g.

k := kite.New("name", "1.0.0")
k.Config.KontrolURL = "http://example.com/kontrol/kite"

Next problem you may encounter is that you'd need to provide also (*Config).KiteKey in order to authenticate to Kontrol.

Looking at the examples I agree it is not clear, they assume (*config.Config).KontrolURL is either read from ~/.kite/kite.key or from environment. In case both places do not have it set, you can get an error as the one you're getting.

This needs to be improved.

@rjeczalik rjeczalik changed the title No kontrol URL given in config examples: state explicitly what is required to use Kontrol API Mar 21, 2017
@HolaYang
Copy link
Author

@HolaYang HolaYang commented Mar 21, 2017

Year, I've configure the environment variables like KONTROL_USERNAME, KONTROL_URL...

And do kontrol -initial, get right result of kitectl showkey.

But in server endpoint, k.Config.KontrolURL is empty

Could you tell me why?

Which step makes it wrong?

@rjeczalik
Copy link
Member

@rjeczalik rjeczalik commented Mar 21, 2017

@Takeoffyoung Can you show me your code just to confirm?

@HolaYang
Copy link
Author

@HolaYang HolaYang commented Mar 21, 2017

package main
import (
    "github.com/koding/kite"
    "net/url"
    "fmt"
)

func main() {
    k := kite.New("first", "1.0.0")
    k.Config.Port = 6000
    fmt.Println(k.Config.KontrolURL)

    k.HandleFunc("square", func(r *kite.Request) (interface{}, error) {
        a := r.Args.One().MustFloat64()
        return a * a, nil
    })

    k.Register(&url.URL{Scheme: "http", Host: "localhost:6000/kite"})
    k.Run()
}

It does not read configuration from neither environment variables nor ~/kite/kite.key .

Above all.

@rjeczalik
Copy link
Member

@rjeczalik rjeczalik commented Mar 21, 2017

@Takeoffyoung kite.New() uses default configuration, it does not read kite.key nor environment.

Your code needs config.Get() or config.MustGet() for that, like this:

https://github.com/koding/kite/blob/master/examples/math-register/math-register.go#L29

@HolaYang
Copy link
Author

@HolaYang HolaYang commented Mar 21, 2017

Oh.... Thx very much.

huh... Maybe I've figured it out, but I am trapped in another trouble.

I am trying it solve it by myself. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup