// Server starts gateway server created from the given configuration. // // It returns a function that can be used to explicitely stop // the kite server. func (d *Driver) Server(cfg *keygen.Config) (cancel func()) { kiteCfg := d.Kite(cfg, "keygen") keygen.NewServer(kiteCfg) go kiteCfg.Kite.Run() <-kiteCfg.Kite.ServerReadyNotify() cfg.ServerURL = fmt.Sprintf("http://127.0.0.1:%d/kite", kiteCfg.Kite.Port()) return kiteCfg.Kite.Close }
// BeforeFunc spies on cfg.BeforeFunc calls, sending passed time.Time // to the returned channel. // // If cfg.BeforeFunc is non-nil, it is called after the value is sent. func (d *Driver) BeforeFunc(cfg *keygen.Config) <-chan time.Time { ch := make(chan time.Time, d.ChanCap) fn := cfg.BeforeFunc cfg.BeforeFunc = func(t time.Time) bool { ch <- t if fn != nil { return fn(t) } return keygen.DefaultBefore(t) } return ch }
// AuthFunc spies on cfg.AuthFunc calls, sending passed AuthRequest // to the returned channel. // // If cfg.AuthFunc is non-nil, it is called after the value is sent. func (d *Driver) AuthFunc(cfg *keygen.Config) <-chan *keygen.AuthRequest { ch := make(chan *keygen.AuthRequest, d.ChanCap) fn := cfg.AuthFunc cfg.AuthFunc = func(req *keygen.AuthRequest) error { ch <- req if fn != nil { return fn(req) } return nil } return ch }