Documentation ¶
Index ¶
- func AuthRoute(h AuthHandler, w http.ResponseWriter, r *http.Request, authType AuthType) http.HandlerFunc
- func GetField(r *http.Request, index int) string
- type AuthHandler
- type AuthType
- type ContextAdapter
- type ContextHandler
- type ContextHandlerFunc
- type Route
- type Router
- func (r *Router) DELETE(pattern string, handler AuthHandler, authType AuthType) Route
- func (r *Router) GET(pattern string, handler AuthHandler, authType AuthType) Route
- func (r *Router) Handle(httpMethod, pattern string, handler AuthHandler, authType AuthType) Route
- func (r *Router) POST(pattern string, handler AuthHandler, authType AuthType) Route
- func (r *Router) PUT(pattern string, handler AuthHandler, authType AuthType) Route
- func (r *Router) PrintRoutes()
- func (r *Router) RegisterMiddleware(handler http.HandlerFunc)
- func (r *Router) ServeHTTP(response http.ResponseWriter, request *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthRoute ¶
func AuthRoute(h AuthHandler, w http.ResponseWriter, r *http.Request, authType AuthType) http.HandlerFunc
AuthRoute populates the custom AuthHandler args for our route handlers
Types ¶
type AuthHandler ¶
type AuthHandler func(user *models.User, w http.ResponseWriter, r *http.Request) http.HandlerFunc
AuthHandler is the extended handler function that our API routes use
type ContextAdapter ¶
type ContextAdapter struct {
// contains filtered or unexported fields
}
func (*ContextAdapter) ServeHTTP ¶
func (ca *ContextAdapter) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type ContextHandler ¶
type ContextHandlerFunc ¶
func (ContextHandlerFunc) ServeHTTPContext ¶
func (h ContextHandlerFunc) ServeHTTPContext(ctx context.Context, rw http.ResponseWriter, req *http.Request)
type Router ¶
type Router struct { MethodNotAllowed http.HandlerFunc NotFound http.HandlerFunc WebsocketHandler http.HandlerFunc // Function to handle panics recovered from http handlers. // Used to keep the server from crashing because of un-recovered panics. PanicHandler func(http.ResponseWriter, *http.Request, interface{}) // contains filtered or unexported fields }
func (*Router) DELETE ¶
func (r *Router) DELETE(pattern string, handler AuthHandler, authType AuthType) Route
DELETE is a shortcut for creating a new Route
func (*Router) GET ¶
func (r *Router) GET(pattern string, handler AuthHandler, authType AuthType) Route
GET is a shortcut for creating a new Route
func (*Router) Handle ¶
func (r *Router) Handle(httpMethod, pattern string, handler AuthHandler, authType AuthType) Route
Handle validates, creates, and appends a Route to the routes array
func (*Router) POST ¶
func (r *Router) POST(pattern string, handler AuthHandler, authType AuthType) Route
POST is a shortcut for creating a new Route
func (*Router) PUT ¶
func (r *Router) PUT(pattern string, handler AuthHandler, authType AuthType) Route
PUT is a shortcut for creating a new Route
func (*Router) PrintRoutes ¶
func (r *Router) PrintRoutes()
PrintRoutes to display in the console/log
func (*Router) RegisterMiddleware ¶
func (r *Router) RegisterMiddleware(handler http.HandlerFunc)
RegisterMiddleware takes a handle function and adds it to the array of middleware handlers
Click to show internal directories.
Click to hide internal directories.