web

package
v0.0.0-...-21b7e91 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID returns the trace id from the context.

func SetStatusCode

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

SetStatusCode sets the status code back into the context.

Types

type App

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

func NewApp

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

NewApp returns a pointer to the App with a configured mux.

func (*App) Handle

func (a *App) Handle(method string, group 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) ServeHTTP

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

ServeHTTP implements the http.Handler interface on App.

func (*App) SignalShutdown

func (a *App) SignalShutdown()

SignalShutdown is used to gracefully shut down the app when an integrity issue is identified.

func (*App) Start

func (a *App) Start() error

type Handler

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

type Middleware

type Middleware func(h Handler) Handler

type Values

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

Values represent state for each request.

func GetValues

func GetValues(ctx context.Context) (*Values, error)

GetValues returns the values from the context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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