rest

package
v0.0.0-...-044f632 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(slug string, err error, w http.ResponseWriter, r *http.Request)

func Conflict

func Conflict(slug string, err error, w http.ResponseWriter, r *http.Request)

func Forbidden

func Forbidden(slug string, err error, w http.ResponseWriter, r *http.Request)

func InternalServerError

func InternalServerError(slug string, err error, w http.ResponseWriter, r *http.Request)

func NewHandler

func NewHandler(params Params) http.Handler

func NotFound

func NotFound(slug string, err error, w http.ResponseWriter, r *http.Request)

func Unauthorized

func Unauthorized(slug string, err error, w http.ResponseWriter, r *http.Request)

func UnprocessableEntity

func UnprocessableEntity(slug string, err error, w http.ResponseWriter, r *http.Request)

Types

type AuthProvider

type AuthProvider interface {
	AuthenticateUser(ctx context.Context, r *http.Request) (User, error)
}

type ErrorResponse

type ErrorResponse struct {
	Slug    string `json:"slug"`
	Details string `json:"details"`
	// contains filtered or unexported fields
}

func (ErrorResponse) Render

type Formatter

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

func (*Formatter) NewLogEntry

func (l *Formatter) NewLogEntry(r *http.Request) middleware.LogEntry

type MetricCollector

type MetricCollector interface {
	IncRequestsCount(status, method, path string)
}

type Middleware

type Middleware func(next http.Handler) http.Handler

func AuthMiddleware

func AuthMiddleware(provider AuthProvider) Middleware

func CORSMiddleware

func CORSMiddleware(allowedOrigins []string) Middleware

func LoggingMiddleware

func LoggingMiddleware(logger service.Logger) Middleware

func MetricsMiddleware

func MetricsMiddleware(metric MetricCollector) Middleware

type Params

type Params struct {
	Middlewares []Middleware
	Routes      []Route
}

type Route

type Route struct {
	Pattern string
	Handler http.Handler
}

type User

type User struct {
	UUID        string
	DisplayName string
}

func UserFromCtx

func UserFromCtx(ctx context.Context) (User, error)

Directories

Path Synopsis
Package v1 provides primitives to interact with the openapi HTTP API.
Package v1 provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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