web

package
v0.0.0-...-720b936 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTime

func GetTime(ctx context.Context) time.Time

func GetTraceID

func GetTraceID(ctx context.Context) string

func IsShutdown

func IsShutdown(err error) bool

func NewShutdownError

func NewShutdownError(message string) error

func Param

func Param(r *http.Request, key string) string

func Respond

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

Respond converts a Go value to JSON and sends it to the client.

Types

type App

type App struct {
	*httptreemux.ContextMux
	// 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, path string, handler Handler, mw ...MiddleWare)

Handle sets a handler function for a given HTTP method and path pair to the application server mux.

func (*App) SignalShutdown

func (a *App) SignalShutdown()

type Handler

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

type MiddleWare

type MiddleWare func(Handler) Handler

MidHandler is a handler function designed to run code before and/or after another Handler. It is designed to remove boilerplate or other concerns not direct to any given app Handler.

type Values

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

func GetValues

func GetValues(ctx context.Context) *Values

Jump to

Keyboard shortcuts

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