Skip to content

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

Description

@tipybara

I do every process in tutorial.

But it raises "No kontrol URL given in config"

What should I do to figure it out?

Activity

  1. rjeczalik commented on Mar 21, 2017

    @rjeczalik
    Contributor

    @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.

  2. changed the title [-]No kontrol URL given in config[/-] [+]examples: state explicitly what is required to use Kontrol API[/+] on Mar 21, 2017
  3. tipybara commented on Mar 21, 2017

    @tipybara
    Author

    Yes, I've set up 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?

  4. rjeczalik commented on Mar 21, 2017

    @rjeczalik
    Contributor

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

  5. tipybara commented on Mar 21, 2017

    @tipybara
    Author
    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.

  6. rjeczalik commented on Mar 21, 2017

    @rjeczalik
    Contributor

    @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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions