stdlib

package module
v0.0.0-...-159dada Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(handlers *gotrust.GenericAuthHandlers) func(http.HandlerFunc) http.HandlerFunc

AuthMiddleware is a convenience function for using auth middleware with standard http

func RegisterRoutes

func RegisterRoutes(mux *http.ServeMux, basePath string, handlers *gotrust.GenericAuthHandlers)

RegisterRoutes registers all auth routes on a ServeMux

func WrapHandler

func WrapHandler(handler gotrust.HTTPHandler) http.HandlerFunc

WrapHandler converts a gotrust.HTTPHandler to http.HandlerFunc

func WrapMiddleware

func WrapMiddleware(middleware gotrust.HTTPMiddleware) func(http.HandlerFunc) http.HandlerFunc

WrapMiddleware converts a gotrust.HTTPMiddleware to standard middleware

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router implements gotrust.Router for standard net/http

func NewRouter

func NewRouter(mux *http.ServeMux) *Router

NewRouter creates a new standard library router

func (*Router) DELETE

func (r *Router) DELETE(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)

DELETE registers a DELETE route

func (*Router) GET

func (r *Router) GET(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)

GET registers a GET route

func (*Router) Group

func (r *Router) Group(prefix string, middleware ...gotrust.HTTPMiddleware) gotrust.Router

Group creates a new route group

func (*Router) POST

func (r *Router) POST(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)

POST registers a POST route

func (*Router) PUT

func (r *Router) PUT(path string, handler gotrust.HTTPHandler, middleware ...gotrust.HTTPMiddleware)

PUT registers a PUT route

type StdContext

type StdContext struct {
	Request  *http.Request
	Response http.ResponseWriter
	// contains filtered or unexported fields
}

StdContext wraps http.Request and http.ResponseWriter to implement gotrust.HTTPContext

func NewStdContext

func NewStdContext(w http.ResponseWriter, r *http.Request) *StdContext

NewStdContext creates a new standard library context

func (*StdContext) Bind

func (c *StdContext) Bind(dest interface{}) error

Bind decodes JSON request body

func (*StdContext) Context

func (c *StdContext) Context() context.Context

Context returns the request context

func (*StdContext) Get

func (c *StdContext) Get(key string) interface{}

Get gets a context value

func (*StdContext) GetCookie

func (c *StdContext) GetCookie(name string) (*http.Cookie, error)

GetCookie gets a cookie

func (*StdContext) GetFormValue

func (c *StdContext) GetFormValue(key string) string

GetFormValue gets a form value

func (*StdContext) GetHeader

func (c *StdContext) GetHeader(key string) string

GetHeader gets a request header

func (*StdContext) GetQueryParam

func (c *StdContext) GetQueryParam(key string) string

GetQueryParam gets a query parameter

func (*StdContext) JSON

func (c *StdContext) JSON(code int, data interface{}) error

JSON sends a JSON response

func (*StdContext) Redirect

func (c *StdContext) Redirect(code int, url string) error

Redirect sends a redirect response

func (*StdContext) Set

func (c *StdContext) Set(key string, value interface{})

Set sets a context value

func (*StdContext) SetCookie

func (c *StdContext) SetCookie(cookie *http.Cookie)

SetCookie sets a cookie

func (*StdContext) SetHeader

func (c *StdContext) SetHeader(key, value string)

SetHeader sets a response header

func (*StdContext) SetStatus

func (c *StdContext) SetStatus(code int)

SetStatus sets the response status code

func (*StdContext) String

func (c *StdContext) String(code int, text string) error

String sends a text response

Jump to

Keyboard shortcuts

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