Documentation ¶
Overview ¶
Package handlers creates HTTP handler functions for registry interface implementations
Index ¶
- Constants
- func AddDsyncReceivers(rec *dsync.Receivers) func(o *RouteOptions)
- func AddPinset(ps pinset.Pinset) func(o *RouteOptions)
- func AddProtector(p MethodProtector) func(o *RouteOptions)
- func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
- func NewAdminKey() string
- func NewDatasetHandler(datasets registry.Datasets, idxr registry.Indexer) http.HandlerFunc
- func NewDatasetsHandler(datasets registry.Datasets, idxr registry.Indexer) http.HandlerFunc
- func NewPinStatusHandler(ps pinset.Pinset) http.HandlerFunc
- func NewPinsHandler(ps pinset.Pinset) http.HandlerFunc
- 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 ¶
const DefaultLimit = 25
DefaultLimit is the default limit of datasets that will get sent back on a dataset list request
Variables ¶
This section is empty.
Functions ¶
func AddDsyncReceivers ¶
func AddDsyncReceivers(rec *dsync.Receivers) func(o *RouteOptions)
AddDsyncReceivers creates a configuration func for passing to NewRoutes
func AddPinset ¶
func AddPinset(ps pinset.Pinset) func(o *RouteOptions)
AddPinset creates a configuration func for passing to NewRoutes
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 NewDatasetHandler ¶
NewDatasetHandler creates a dataset handler func that operats on a *registry.Datasets
func NewDatasetsHandler ¶
NewDatasetsHandler creates a datasets handler function that operates on a *registry.Datasets
func NewPinStatusHandler ¶
func NewPinStatusHandler(ps pinset.Pinset) http.HandlerFunc
NewPinStatusHandler creates a handler for getting the pin status of a hash
func NewPinsHandler ¶
func NewPinsHandler(ps pinset.Pinset) http.HandlerFunc
NewPinsHandler creates a profiles handler function that operates on a *registry.Profiles
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 Pinset pinset.Pinset Dsync *dsync.Receivers }
RouteOptions defines configuration details for NewRoutes