web

package
v0.0.0-...-38a15d6 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 7 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

GetTime returns the time from the context.

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID returns the trace id from the context.

func Respond

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

Types

type App

type App struct {
	*http.ServeMux
	// contains filtered or unexported fields
}

func NewApp

func NewApp(shutdown chan os.Signal, log Logger, mw ...MidHandler) *App

func (*App) HandleFunc

func (a *App) HandleFunc(pattern string, handler Handler, mw ...MidHandler)

This is an override of the promoted API method from the embedded ServeMux.

func (*App) HandleFuncNoMiddleware

func (a *App) HandleFuncNoMiddleware(pattern string, handler Handler, mw ...MidHandler)

type Handler

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

type Logger

type Logger func(ctx context.Context, msg string, v ...any)

type MidHandler

type MidHandler func(Handler) Handler

MidHandler is a type that represents a middleware handler, which is a function that takes a handler and returns a handler. This is a common pattern in Go for creating middleware chains & run code before and after another handler.

type Values

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

Values is a struct that represent state for each request.

func GetValues

func GetValues(ctx context.Context) *Values

GetValues returns the values from the context.

Jump to

Keyboard shortcuts

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