httpext

package
v1.3.16 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Platform             = "HTTP"
	ContentTypeHeader    = "Content-Type"
	CharsetHeader        = "Accept-Charset"
	AcceptHeader         = "Accept"
	AuthorizationHeader  = "Authorization"
	RealIPHeader         = "X-Real-IP"
	AcceptLanguageHeader = "Accept-Language"
)

Variables

View Source
var (
	DefaultCors = cors.New(cors.Options{
		AllowedOrigins: []string{"*"},
		AllowedMethods: []string{
			http.MethodGet,
			http.MethodPost,
			http.MethodPut,
			http.MethodPatch,
			http.MethodDelete,
			http.MethodOptions,
		},
		AllowedHeaders: []string{"*"},
	})
)
View Source
var (
	ErrInvalidToken = errors.New(codes.Unauthenticated).WithDetails("invalid Authenticate")
)

Functions

func AuthHeader

func AuthHeader(req *http.Request) (authenticate.Authenticate, error)

func BindModel

func BindModel(req *http.Request, model any) (err error)

func DetectLangMiddleware added in v1.3.1

func DetectLangMiddleware() mux.MiddlewareFunc
func Header(req *http.Request, key string) string

func RealIP added in v1.2.1

func RealIP(req *http.Request) string

func Send

func Send(res http.ResponseWriter, req *http.Request, code int, mime string, data []byte)

func SendCode

func SendCode(res http.ResponseWriter, req *http.Request, code int)

func SendError

func SendError(res http.ResponseWriter, req *http.Request, err error)

func SendModel

func SendModel(res http.ResponseWriter, req *http.Request, code int, model any)

Types

type Configs

type Configs struct {
	HttpPort netext.Port `env:"HTTP_PORT" envDefault:"8080"`
}

Jump to

Keyboard shortcuts

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