server

package
v0.0.0-...-ffd9c73 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(config settings.HTTP, logger Logger,
	metrics Metrics, buildInfo models.BuildInformation,
	proc Processor) *chi.Mux

Types

type Logger

type Logger interface {
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Error(s string)
}

type Metrics

type Metrics interface {
	RequestCountInc(routePattern string, statusCode int)
	ResponseBytesCountAdd(routePattern string, statusCode int, bytesWritten int)
	InflightRequestsGaugeAdd(addition int)
	ResponseTimeHistogramObserve(routePattern string, statusCode int, duration time.Duration)
}

type Processor

type Processor interface {
	CreateUser(ctx context.Context, user models.User) error
	GetUserByID(ctx context.Context, id uint64) (user models.User, err error)
}

Directories

Path Synopsis
Package contenttype contains functions to extract content type information from request headers as well as set correct headers on the response depending on the Accept and Content-Type request headers.
Package contenttype contains functions to extract content type information from request headers as well as set correct headers on the response depending on the Accept and Content-Type request headers.
Package decodejson has helper functions to decode HTTP bodies encoded in JSON.
Package decodejson has helper functions to decode HTTP bodies encoded in JSON.
Package httperr implements convenience functions to respond with an error to an http client.
Package httperr implements convenience functions to respond with an error to an http client.
middlewares
cors
Package cors has a middleware and functions to parse and set CORS correctly.
Package cors has a middleware and functions to parse and set CORS correctly.
log
metrics
Package metrics implements a metrics middleware for an HTTP server that records metrics data for Prometheus.
Package metrics implements a metrics middleware for an HTTP server that records metrics data for Prometheus.
routes
build
Package build is the HTTP handler for the build information.
Package build is the HTTP handler for the build information.
users
Package users is the HTTP handler for the users.
Package users is the HTTP handler for the users.

Jump to

Keyboard shortcuts

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