Documentation
¶
Index ¶
- func AuthMiddleware(handlers *gotrust.GenericAuthHandlers) func(http.HandlerFunc) http.HandlerFunc
- func RegisterRoutes(mux *http.ServeMux, basePath string, handlers *gotrust.GenericAuthHandlers)
- func WrapHandler(handler gotrust.HTTPHandler) http.HandlerFunc
- func WrapMiddleware(middleware gotrust.HTTPMiddleware) func(http.HandlerFunc) http.HandlerFunc
- type Router
- func (r *Router) DELETE(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
- func (r *Router) GET(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
- func (r *Router) Group(prefix string, middleware ...gotrust.HTTPMiddleware) gotrust.Router
- func (r *Router) POST(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
- func (r *Router) PUT(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
- type StdContext
- func (c *StdContext) Bind(dest interface{}) error
- func (c *StdContext) Context() context.Context
- func (c *StdContext) Get(key string) interface{}
- func (c *StdContext) GetCookie(name string) (*http.Cookie, error)
- func (c *StdContext) GetFormValue(key string) string
- func (c *StdContext) GetHeader(key string) string
- func (c *StdContext) GetQueryParam(key string) string
- func (c *StdContext) JSON(code int, data interface{}) error
- func (c *StdContext) Redirect(code int, url string) error
- func (c *StdContext) Set(key string, value interface{})
- func (c *StdContext) SetCookie(cookie *http.Cookie)
- func (c *StdContext) SetHeader(key, value string)
- func (c *StdContext) SetStatus(code int)
- func (c *StdContext) String(code int, text string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(handlers *gotrust.GenericAuthHandlers) func(http.HandlerFunc) http.HandlerFunc
AuthMiddleware is a convenience function for using auth middleware with standard http
func RegisterRoutes ¶
func RegisterRoutes(mux *http.ServeMux, basePath string, handlers *gotrust.GenericAuthHandlers)
RegisterRoutes registers all auth routes on a ServeMux
func WrapHandler ¶
func WrapHandler(handler gotrust.HTTPHandler) http.HandlerFunc
WrapHandler converts a gotrust.HTTPHandler to http.HandlerFunc
func WrapMiddleware ¶
func WrapMiddleware(middleware gotrust.HTTPMiddleware) func(http.HandlerFunc) http.HandlerFunc
WrapMiddleware converts a gotrust.HTTPMiddleware to standard middleware
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router implements gotrust.Router for standard net/http
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
DELETE registers a DELETE route
func (*Router) GET ¶
func (r *Router) GET(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
GET registers a GET route
func (*Router) POST ¶
func (r *Router) POST(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
POST registers a POST route
func (*Router) PUT ¶
func (r *Router) PUT(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)
PUT registers a PUT route
type StdContext ¶
type StdContext struct {
Request *http.Request
Response http.ResponseWriter
// contains filtered or unexported fields
}
StdContext wraps http.Request and http.ResponseWriter to implement gotrust.HTTPContext
func NewStdContext ¶
func NewStdContext(w http.ResponseWriter, r *http.Request) *StdContext
NewStdContext creates a new standard library context
func (*StdContext) Bind ¶
func (c *StdContext) Bind(dest interface{}) error
Bind decodes JSON request body
func (*StdContext) Context ¶
func (c *StdContext) Context() context.Context
Context returns the request context
func (*StdContext) GetCookie ¶
func (c *StdContext) GetCookie(name string) (*http.Cookie, error)
GetCookie gets a cookie
func (*StdContext) GetFormValue ¶
func (c *StdContext) GetFormValue(key string) string
GetFormValue gets a form value
func (*StdContext) GetHeader ¶
func (c *StdContext) GetHeader(key string) string
GetHeader gets a request header
func (*StdContext) GetQueryParam ¶
func (c *StdContext) GetQueryParam(key string) string
GetQueryParam gets a query parameter
func (*StdContext) JSON ¶
func (c *StdContext) JSON(code int, data interface{}) error
JSON sends a JSON response
func (*StdContext) Redirect ¶
func (c *StdContext) Redirect(code int, url string) error
Redirect sends a redirect response
func (*StdContext) Set ¶
func (c *StdContext) Set(key string, value interface{})
Set sets a context value
func (*StdContext) SetCookie ¶
func (c *StdContext) SetCookie(cookie *http.Cookie)
SetCookie sets a cookie
func (*StdContext) SetHeader ¶
func (c *StdContext) SetHeader(key, value string)
SetHeader sets a response header
func (*StdContext) SetStatus ¶
func (c *StdContext) SetStatus(code int)
SetStatus sets the response status code