controller

package
v0.0.0-...-f158767 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionKey = "sessionKey"
)
View Source
const (
	UserIDKey = "userID"
)

Variables

This section is empty.

Functions

func ControllerHandler

func ControllerHandler[T any](handler func(*http.Request) (*HTTPResponse[T], error)) http.HandlerFunc

func GetContextParam

func GetContextParam[T any](varName string, ctx context.Context) T

func Router

func Router() chi.Router

func SetContextParam

func SetContextParam(varName string, value any, ctx context.Context) context.Context

Types

type CtxKey

type CtxKey string

type HTTPError

type HTTPError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Err     error  `json:"error"`
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) Unwrap

func (e *HTTPError) Unwrap() error

type HTTPResponse

type HTTPResponse[T any] struct {
	StatusCode int
	HasBody    bool
	Body       T
}

func NewOKResponse

func NewOKResponse[T any](body T) *HTTPResponse[T]

func NewResponse

func NewResponse[T any](code int, body T) *HTTPResponse[T]

func NewStatusResponse

func NewStatusResponse[T any](code int) *HTTPResponse[T]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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