handlers

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Defines handlers, kind of like base classes for endpoints

Example (MakePath)
fmt.Println(MakeEndpointPath("roi", "sol", "experiment", "name"))
fmt.Println(MakeEndpointPath("/roi", "did", "name"))
fmt.Println(MakeEndpointPath("roi", "sol/", "/experiment", "/name"))
fmt.Println(MakeEndpointPath("/roi", "name"))
Output:

/roi/{sol}/{experiment}/{name}
/roi/{did}/{name}
/roi/{sol}/{experiment}/{name}
/roi/{name}

Index

Examples

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 ApiHandlerFunc

type ApiHandlerFunc func(ApiHandlerParams) (interface{}, 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   pixlUser.UserInfo
	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 ApiHandlerJSON

type ApiHandlerJSON struct {
	*services.APIServices
	Handler ApiHandlerFunc
}

func (ApiHandlerJSON) ServeHTTP

func (h ApiHandlerJSON) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ApiHandlerParams

type ApiHandlerParams struct {
	Svcs       *services.APIServices
	UserInfo   pixlUser.UserInfo
	PathParams map[string]string
	Request    *http.Request
}

If returning JSON, use this

type ApiHandlerStreamParams

type ApiHandlerStreamParams struct {
	Svcs       *services.APIServices
	UserInfo   pixlUser.UserInfo
	PathParams map[string]string
	Headers    http.Header
}

If it's a handler that streams a file from S3 to the client, use this

type ApiSharingHandler

type ApiSharingHandler struct {
	*services.APIServices
	Share ApiHandlerFunc
}

If it's a share function, use this. Enforces that method is only POST

func (ApiSharingHandler) ServeHTTP

func (h ApiSharingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ApiStreamFromS3Handler

type ApiStreamFromS3Handler struct {
	*services.APIServices
	Stream ApiStreamHandlerFunc
}

func (ApiStreamFromS3Handler) ServeHTTP

type ApiStreamHandlerFunc

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

Jump to

Keyboard shortcuts

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