apiRouter

package
v4.32.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

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

View Source
const HostParamName = "hostname"
View Source
const UrlStreamDownloadIndicator = "download"

Variables

This section is empty.

Functions

func MakeEndpointPath

func MakeEndpointPath(pathPrefix string, pathParamNames ...string) string

Public general-purpose functions

Types

type ApiCacheControlledStreamFromS3Handler

type ApiCacheControlledStreamFromS3Handler struct {
	*services.APIServices
	Stream ApiCacheControlledStreamHandlerFunc
}

func (ApiCacheControlledStreamFromS3Handler) ServeHTTP

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

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

type ApiStreamHandlerFunc

type ApiStreamHandlerFunc func(ApiHandlerStreamParams) (*s3.GetObjectOutput, string, error)

type MethodPermission

type MethodPermission struct {
	Method     string
	Permission string
}

func MakeMethodPermission

func MakeMethodPermission(method string, permission string) MethodPermission

type RouteMethodPermissions

type RouteMethodPermissions map[string]string

Jump to

Keyboard shortcuts

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