Documentation ¶
Overview ¶
Package handlers creates HTTP handler functions for registry interface implementations
Index ¶
- func AddProtector(p MethodProtector) func(o *RouteOptions)
- func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
- func NewAdminKey() string
- func NewProfileHandler(profiles registry.Profiles) http.HandlerFunc
- func NewProfilesHandler(profiles registry.Profiles) http.HandlerFunc
- func NewReputationHandler(rs registry.Reputations) http.HandlerFunc
- func NewRoutes(reg registry.Registry, opts ...func(o *RouteOptions)) *http.ServeMux
- func NewSearchHandler(s registry.Searchable) http.HandlerFunc
- func SetLogLevel(level string) error
- type BAProtector
- type MethodProtector
- type NoopProtector
- type RouteOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddProtector ¶
func AddProtector(p MethodProtector) func(o *RouteOptions)
AddProtector creates a configuration func for passing to NewRoutes
func HealthCheckHandler ¶
func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
HealthCheckHandler is a basic "hey I'm fine" for load balancers & co
func NewAdminKey ¶
func NewAdminKey() string
NewAdminKey generates a randomized key for admin work this is a lazy stopgap for now
func NewProfileHandler ¶
func NewProfileHandler(profiles registry.Profiles) http.HandlerFunc
NewProfileHandler creates a profile handler func that operats on a *registry.Profiles
func NewProfilesHandler ¶
func NewProfilesHandler(profiles registry.Profiles) http.HandlerFunc
NewProfilesHandler creates a profiles handler function that operates on a *registry.Profiles
func NewReputationHandler ¶
func NewReputationHandler(rs registry.Reputations) http.HandlerFunc
NewReputationHandler creates a profile handler func that operates on a *registry.Reputations
func NewRoutes ¶
func NewRoutes(reg registry.Registry, opts ...func(o *RouteOptions)) *http.ServeMux
NewRoutes allocates server handlers along standard routes
func NewSearchHandler ¶
func NewSearchHandler(s registry.Searchable) http.HandlerFunc
NewSearchHandler creates a search handler function taht operates on a *registry.Searchable
func SetLogLevel ¶
SetLogLevel controls how detailed handler logging is
Types ¶
type BAProtector ¶
type BAProtector struct {
// contains filtered or unexported fields
}
BAProtector implements HTTP Basic Auth checking as a protector
func NewBAProtector ¶
func NewBAProtector(username, password string) BAProtector
NewBAProtector creates a HTTP basic auth protector from a username/password combo
func (BAProtector) ProtectMethods ¶
func (ba BAProtector) ProtectMethods(methods ...string) func(http.HandlerFunc) http.HandlerFunc
ProtectMethods implements the MethodProtector interface
type MethodProtector ¶
type MethodProtector interface { // ProtectMethods should accept a list of http request methods and return a function that // generates middleware to screen for authorization on those methods. // // For example if "reqHandler" is an http.HandlerFunc, the following would check for // authentication on all POST requests: // Protector.ProtectMethods("POST")(reqHandler) ProtectMethods(methods ...string) func(h http.HandlerFunc) http.HandlerFunc }
MethodProtector is an interface for controling access to http.HandlerFunc's according to request method (GET, PUT, POST, etc.)
type NoopProtector ¶
type NoopProtector uint8
NoopProtector implements the MethodProtector without doing any checks
func NewNoopProtector ¶
func NewNoopProtector() NoopProtector
NewNoopProtector creates a NoopProtector
func (NoopProtector) ProtectMethods ¶
func (NoopProtector) ProtectMethods(methods ...string) func(http.HandlerFunc) http.HandlerFunc
ProtectMethods implements the MethodProtector interface
type RouteOptions ¶
type RouteOptions struct {
Protector MethodProtector
}
RouteOptions defines configuration details for NewRoutes