routes

package
v0.0.0-...-d208a3a Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonSender

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

func (*JsonSender) Send

func (r *JsonSender) Send(ctx context.Context, w http.ResponseWriter, status int, body any)

Send returns a JSON response with the given status code and body. If marshalling fails, it will return a 500 response with the error message.

type Middeware

type Middeware func(http.HandlerFunc) http.HandlerFunc

type Route

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

func NewRoute

func NewRoute(method string, path string, handler http.HandlerFunc) *Route

func (*Route) Method

func (r *Route) Method() string

func (*Route) Path

func (r *Route) Path() string

func (*Route) Register

func (r *Route) Register(mux *http.ServeMux)

func (*Route) WithMiddleware

func (r *Route) WithMiddleware(mws ...Middeware) *Route

type Sender

type Sender interface {

	// Send marshals the body and sends it as a response with the given status code.
	// If marshalling fails, it will return a 500 response with the error message.
	Send(ctx context.Context, w http.ResponseWriter, status int, body any)
}

func NewJsonSender

func NewJsonSender(logger logging.Logger) Sender

type Services

type Services struct {
	Logger           logging.Logger
	Metrics          metrics.Metrics
	Vault            *vault.Service
	Ratelimit        ratelimit.Service
	OpenApiValidator validation.OpenAPIValidator
	Sender           Sender
}

Jump to

Keyboard shortcuts

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