httpUtils

package
v0.0.0-...-1d800d4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Age

func Age(c *Context, age int64)

func EndTotalTimer

func EndTotalTimer(c *Context)

func GetAndLogErrResponseDetails

func GetAndLogErrResponseDetails(c *Context, err error) (int, string)

func GetId

func GetId(c *Context, name string) sharedTypes.UUID

func ListenAndServe

func ListenAndServe(server Server, addr string) error

func ListenAndServeEach

func ListenAndServeEach(do func(func() error), server Server, each []string)

func MustParseJSON

func MustParseJSON(dst interface{}, c *Context) bool

func ParseAndValidateId

func ParseAndValidateId(c *Context, name string) (sharedTypes.UUID, error)

func ProcessFileUpload

func ProcessFileUpload(d *UploadDetails, c *Context, memoryLimit int64) bool

func Redirect

func Redirect(c *Context, target string)

func Respond

func Respond(c *Context, code int, body interface{}, err error)

func RespondErr

func RespondErr(c *Context, err error)

func RespondPlain

func RespondPlain(c *Context, status int, body string)

func RespondWithIndent

func RespondWithIndent(c *Context, code int, body interface{}, err error)

func TimeStage

func TimeStage(c *Context, label string) func()

Types

type CORSOptions

type CORSOptions struct {
	SiteOrigin      string
	AllowOrigins    []string
	AllowWebsockets bool
}

type Context

type Context struct {
	Writer  http.ResponseWriter
	Request *http.Request
	// contains filtered or unexported fields
}

func (Context) AddValue

func (c Context) AddValue(key interface{}, v interface{}) *Context

func (*Context) ClientIP

func (c *Context) ClientIP() string

ClientIP returns the last IP of the last X-Forwarded-For header on the request, if any, else it returns the requests .RemoteAddr.

func (*Context) Param

func (c *Context) Param(key string) string

func (*Context) T0

func (c *Context) T0() time.Time

type HandlerFunc

type HandlerFunc func(c *Context)

func (HandlerFunc) ServeHTTP

func (f HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JWT

type JWT interface {
	jwtHandler.JWT
	PostProcess(c *Context) (*Context, error)
}

type JWTHTTPHandler

type JWTHTTPHandler[T JWT] struct {
	// contains filtered or unexported fields
}

func NewJWTHandler

func NewJWTHandler[T JWT](handler *jwtHandler.JWTHandler[T]) *JWTHTTPHandler[T]

func (*JWTHTTPHandler[T]) Middleware

func (h *JWTHTTPHandler[T]) Middleware() MiddlewareFunc

func (*JWTHTTPHandler[T]) Parse

func (h *JWTHTTPHandler[T]) Parse(c *Context) (*Context, error)

type MiddlewareFunc

type MiddlewareFunc func(next HandlerFunc) HandlerFunc

func CORS

func CORS(options CORSOptions) MiddlewareFunc

func ValidateAndSetId

func ValidateAndSetId(name string) MiddlewareFunc

func ValidateAndSetIdZeroOK

func ValidateAndSetIdZeroOK(name string) MiddlewareFunc

type Router

type Router struct {
	*mux.Router
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(options *RouterOptions) *Router

func (*Router) DELETE

func (r *Router) DELETE(endpoint string, f HandlerFunc)

func (*Router) GET

func (r *Router) GET(endpoint string, f HandlerFunc)

func (*Router) Group

func (r *Router) Group(partial string) *Router

func (*Router) HEAD

func (r *Router) HEAD(endpoint string, f HandlerFunc)

func (*Router) NoRoute

func (r *Router) NoRoute(f HandlerFunc)

func (*Router) POST

func (r *Router) POST(endpoint string, f HandlerFunc)

func (*Router) PUT

func (r *Router) PUT(endpoint string, f HandlerFunc)

func (*Router) Use

func (r *Router) Use(fns ...MiddlewareFunc)

type RouterOptions

type RouterOptions struct {
	Ready func() bool
}

type Server

type Server interface {
	Serve(listener net.Listener) error
	Shutdown(ctx context.Context) error
}

type UploadDetails

type UploadDetails struct {
	File multipart.File

	FileName sharedTypes.Filename
	Size     int64
	// contains filtered or unexported fields
}

func (*UploadDetails) Cleanup

func (d *UploadDetails) Cleanup()

Jump to

Keyboard shortcuts

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