handlers

package
v0.9.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 9 Imported by: 1

Documentation

Overview

Package handlers creates HTTP handler functions for registry interface implementations

Index

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 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

func SetLogLevel(level string) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL