xrest

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = CORSConfig{
	AllowOrigin: "*",
	AllowMethods: []string{
		http.MethodGet,
		http.MethodHead,
		http.MethodPut,
		http.MethodPatch,
		http.MethodPost,
		http.MethodDelete,
	},
}

Functions

func CORS

func CORS() func(next http.Handler) http.Handler

func CORSWithConfig

func CORSWithConfig(config CORSConfig) func(next http.Handler) http.Handler

func Chain

func Chain(middlewares ...func(next http.Handler) http.Handler) func(next http.Handler) http.Handler

func Context

func Context() func(next http.Handler) http.Handler

func Debug

func Debug(prefix string) http.Handler

func Documentation

func Documentation(name, prefix string, spec []byte) http.Handler

func Error

func Error(r *http.Request, err error)

func Get

func Get[T any](r *http.Request, key string) (val T, ok bool)

func GetError

func GetError(r *http.Request) error

func Set

func Set[T any](r *http.Request, key string, value T)

Types

type CORSConfig

type CORSConfig struct {
	AllowOrigin  string
	AllowMethods []string
}

Jump to

Keyboard shortcuts

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