Documentation ¶
Overview ¶
The guts of PIXLISE API endpoint handler/routing code. Allows us to define a router, permissions, and services to be used by code that processes HTTP requests.
Index ¶
- Constants
- func MakeEndpointPath(pathPrefix string, pathParamNames ...string) string
- type ApiCacheControlledStreamFromS3Handler
- type ApiCacheControlledStreamHandlerFunc
- type ApiHandlerGeneric
- type ApiHandlerGenericFunc
- type ApiHandlerGenericParams
- type ApiHandlerGenericPublic
- type ApiHandlerGenericPublicFunc
- type ApiHandlerGenericPublicParams
- type ApiHandlerStreamParams
- type ApiObjectRouter
- func (r *ApiObjectRouter) AddCacheControlledStreamHandler(path string, methodPerm MethodPermission, ...)
- func (r *ApiObjectRouter) AddGenericHandler(path string, methodPerm MethodPermission, handleFunc ApiHandlerGenericFunc)
- func (r *ApiObjectRouter) AddPublicHandler(path string, method string, handleFunc ApiHandlerGenericPublicFunc)
- func (r *ApiObjectRouter) GetPermissions() RouteMethodPermissions
- type ApiStreamFromS3Handler
- type ApiStreamHandlerFunc
- type MethodPermission
- type RouteMethodPermissions
Constants ¶
View Source
const HostParamName = "hostname"
View Source
const UrlStreamDownloadIndicator = "download"
Variables ¶
This section is empty.
Functions ¶
func MakeEndpointPath ¶
Public general-purpose functions
Types ¶
type ApiCacheControlledStreamFromS3Handler ¶
type ApiCacheControlledStreamFromS3Handler struct { *services.APIServices Stream ApiCacheControlledStreamHandlerFunc }
func (ApiCacheControlledStreamFromS3Handler) ServeHTTP ¶
func (h ApiCacheControlledStreamFromS3Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ApiCacheControlledStreamHandlerFunc ¶
type ApiCacheControlledStreamHandlerFunc func(ApiHandlerStreamParams) (*s3.GetObjectOutput, string, string, string, int, error)
type ApiHandlerGeneric ¶
type ApiHandlerGeneric struct { *services.APIServices Handler ApiHandlerGenericFunc }
func (ApiHandlerGeneric) ServeHTTP ¶
func (h ApiHandlerGeneric) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ApiHandlerGenericFunc ¶
type ApiHandlerGenericFunc func(ApiHandlerGenericParams) error
type ApiHandlerGenericParams ¶
type ApiHandlerGenericParams struct { Svcs *services.APIServices UserInfo jwtparser.JWTUserInfo PathParams map[string]string Writer http.ResponseWriter Request *http.Request }
If all else fails, use this. Is the most generic handler, passes in request & response writer like raw ServeHTTP but also passed the parsed user info & path params
type ApiHandlerGenericPublic ¶
type ApiHandlerGenericPublic struct { *services.APIServices Handler ApiHandlerGenericPublicFunc }
func (ApiHandlerGenericPublic) ServeHTTP ¶
func (h ApiHandlerGenericPublic) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ApiHandlerGenericPublicFunc ¶
type ApiHandlerGenericPublicFunc func(ApiHandlerGenericPublicParams) error
type ApiHandlerGenericPublicParams ¶
type ApiHandlerGenericPublicParams struct { Svcs *services.APIServices PathParams map[string]string Writer http.ResponseWriter Request *http.Request }
As with generic handler, but for public API endpoints ONLY
type ApiHandlerStreamParams ¶
type ApiHandlerStreamParams struct { Svcs *services.APIServices UserInfo jwtparser.JWTUserInfo PathParams map[string]string Headers http.Header }
If it's a handler that streams a file from S3 to the client, use this
type ApiObjectRouter ¶
type ApiObjectRouter struct { Permissions RouteMethodPermissions Svcs *services.APIServices Router *mux.Router }
func NewAPIRouter ¶
func NewAPIRouter(svcs *services.APIServices, router *mux.Router) ApiObjectRouter
func (*ApiObjectRouter) AddCacheControlledStreamHandler ¶
func (r *ApiObjectRouter) AddCacheControlledStreamHandler(path string, methodPerm MethodPermission, handleFunc ApiCacheControlledStreamHandlerFunc)
func (*ApiObjectRouter) AddGenericHandler ¶
func (r *ApiObjectRouter) AddGenericHandler(path string, methodPerm MethodPermission, handleFunc ApiHandlerGenericFunc)
func (*ApiObjectRouter) AddPublicHandler ¶
func (r *ApiObjectRouter) AddPublicHandler(path string, method string, handleFunc ApiHandlerGenericPublicFunc)
func (*ApiObjectRouter) GetPermissions ¶
func (r *ApiObjectRouter) GetPermissions() RouteMethodPermissions
type ApiStreamFromS3Handler ¶
type ApiStreamFromS3Handler struct { *services.APIServices Stream ApiStreamHandlerFunc }
func (ApiStreamFromS3Handler) ServeHTTP ¶
func (h ApiStreamFromS3Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ApiStreamHandlerFunc ¶
type ApiStreamHandlerFunc func(ApiHandlerStreamParams) (*s3.GetObjectOutput, string, error)
type MethodPermission ¶
func MakeMethodPermission ¶
func MakeMethodPermission(method string, permission string) MethodPermission
type RouteMethodPermissions ¶
Click to show internal directories.
Click to hide internal directories.