web

package
v0.0.0-...-7428172 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r *http.Request, dest any) error

func GetStatusCode

func GetStatusCode(ctx context.Context) string

func GetTraceID

func GetTraceID(ctx context.Context) string

func IsShutdownError

func IsShutdownError(err error) bool

func NewShutdownError

func NewShutdownError(message string) error

func Response

func Response(ctx context.Context, w http.ResponseWriter, statusCode int, data any) error

func SetStatusCode

func SetStatusCode(ctx context.Context, statusCode int) error

Types

type App

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

func NewApp

func NewApp(shutdown chan os.Signal, mw ...Middleware) *App

func (*App) Handle

func (a *App) Handle(method string, version string, path string, handler Handler, mw ...Middleware)

func (*App) ServeHTTP

func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*App) Shutdown

func (a *App) Shutdown()

type CtxValues

type CtxValues struct {
	TraceID    string
	Now        time.Time
	StatusCode int
}

func GetCtxValues

func GetCtxValues(ctx context.Context) (*CtxValues, error)

type Handler

type Handler func(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Handler represents type responsible for handling http request. It extends signature of http.HandlerFunc with support for context.Context.

type Middleware

type Middleware func(Handler) Handler

Jump to

Keyboard shortcuts

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