route

package
v0.0.0-...-1967991 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package route contains the request context. Each request will have its own instance of RequestContext filled by the middleware code in the api-context-wrapper.go (parent package).

Each value here should be assumed valid only per request only, with some exceptions like the logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnonymousRoute

type AnonymousRoute struct {
	Method  string
	Path    string
	Handler Handler
}

func (AnonymousRoute) GetMethod

func (route AnonymousRoute) GetMethod() string

func (AnonymousRoute) GetPath

func (route AnonymousRoute) GetPath() string

func (AnonymousRoute) IsSecure

func (route AnonymousRoute) IsSecure() bool

type AuthMiddleware

type AuthMiddleware interface {
	Intercept(handler SecureHandler) Handler
}

type Controller

type Controller interface {
	ListRoutes() []Route
}

type Handler

type Handler = func(
	w http.ResponseWriter,
	r *http.Request,
	params httprouter.Params,
	context RequestContext,
)

type Middleware

type Middleware = func(handler Handler) Handler

type RequestContext

type RequestContext struct {
	// ReqUUID is the request unique ID
	ReqUUID uuid.UUID

	// Logger is a custom field logger for the request
	Logger logrus.FieldLogger
}

RequestContext is the context of the request, for request-dependent parameters

type Route

type Route interface {
	GetMethod() string
	GetPath() string
	IsSecure() bool
}

Route is the description of an endpoint / API route. A controller will return the list of its routes, instead of registering them directly to be independent of the underlying routing library.

type SecureHandler

type SecureHandler func(
	w http.ResponseWriter,
	r *http.Request,
	params httprouter.Params,
	context SecureRequestContext,
)

type SecureRequestContext

type SecureRequestContext struct {
	UserId string
	RequestContext
}

type SecureRoute

type SecureRoute struct {
	Method  string
	Path    string
	Handler SecureHandler
}

func (SecureRoute) GetMethod

func (route SecureRoute) GetMethod() string

func (SecureRoute) GetPath

func (route SecureRoute) GetPath() string

func (SecureRoute) IsSecure

func (route SecureRoute) IsSecure() bool

Jump to

Keyboard shortcuts

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