NewWithoutHandlers creates a new kontrol instance with the given version and config instance, but *without* the default handlers. If this is function is used, make sure to implement the expected kontrol functionality. Example: kontrol := NewWithoutHandlers(conf, version) kontrol.Kite.HandleFunc("r
(conf *config.Config, version string)
| 168 | // kontrol.Kite.HandleHTTPFunc("/register", kontrol.HandleRegisterHTTP) |
| 169 | // |
| 170 | func NewWithoutHandlers(conf *config.Config, version string) *Kontrol { |
| 171 | k := &Kontrol{ |
| 172 | clientLocks: NewIdlock(), |
| 173 | heartbeats: make(map[string]*heartbeat), |
| 174 | closed: make(chan struct{}), |
| 175 | tokenCache: make(map[string]cachedToken), |
| 176 | } |
| 177 | |
| 178 | // Make a copy to not modify user-provided value. |
| 179 | conf = conf.Copy() |
| 180 | |
| 181 | // Listen on 4000 by default. |
| 182 | if conf.Port == 0 { |
| 183 | conf.Port = DefaultPort |
| 184 | } |
| 185 | |
| 186 | // Allow keys that were recently deleted - for Register{,HTTP} to |
| 187 | // give client kite a chance to update them. |
| 188 | if conf.VerifyFunc == nil { |
| 189 | conf.VerifyFunc = k.Verify |
| 190 | } |
| 191 | |
| 192 | k.Kite = kite.NewWithConfig("kontrol", version, conf) |
| 193 | k.log = k.Kite.Log |
| 194 | |
| 195 | return k |
| 196 | } |
| 197 | |
| 198 | // Verify is used for token and kiteKey authenticators to verify |
| 199 | // client's kontrol keys. In order to allow for graceful key |