We should consider exposing a Run method that supports minimal viable configuration and starts a server.
This will make getting started much easier, and avoid having to set up every dependency (logging, HTTP server, routing, middleware) if a user doesn’t have strict opinions on these things. See cmd/admissiond for an example.
Proposed API:
- Expose an AdmissionServer type, with a NewAdmissionServer constructor that accepts a
*http.Server, a log.Logger (maybe?), and a map[string]AdmitFunc that maps URL paths to the provided handlers.
- Extra (optional) config can be exposed as struct fields; otherwise we use opinionated defaults
- Create a
Run(ctx) error method that starts the HTTP server.
Users with custom requirements can continue to build their own servers around the http.Handler compatible AdmissionHandler type.
We should consider exposing a
Runmethod that supports minimal viable configuration and starts a server.This will make getting started much easier, and avoid having to set up every dependency (logging, HTTP server, routing, middleware) if a user doesn’t have strict opinions on these things. See
cmd/admissiondfor an example.Proposed API:
*http.Server, alog.Logger(maybe?), and amap[string]AdmitFuncthat maps URL paths to the provided handlers.Run(ctx) errormethod that starts the HTTP server.Users with custom requirements can continue to build their own servers around the
http.HandlercompatibleAdmissionHandlertype.