middleware

package
v0.0.0-...-feb181f Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IdentityRequestKey = &contextKey{"authnapi.Identity"}
	GetIdentity        = GetFromContext[authnapi.Identity](IdentityRequestKey)
)
View Source
var (
	PaginationRequestKey = &contextKey{"paginationRequest"}
	GetPaginationRequest = GetFromContext[PaginationRequest](PaginationRequestKey)
)
View Source
var (
	ErrWrongContext = errors.Unauthorized(reason, "Wrong context for middleware")
)

Functions

func Authentication

func Authentication(authenticator authnapi.Authenticator) func(middleware.Handler) middleware.Handler

func GetFromContext

func GetFromContext[V any, I any](i I) func(context.Context) (*V, error)

func Pagination

func Pagination(next http.Handler) http.Handler

func Validation

func Validation(validator *protovalidate.Validator) middleware.Middleware

Types

type PagedReponseMetadata

type PagedReponseMetadata struct {
	Page  int   `json:"page"`
	Size  int   `json:"size"`
	Total int64 `json:"total"`
}

type PagedResponse

type PagedResponse[R any] struct {
	PagedReponseMetadata
	Items []R `json:"items"`
}

type PaginationRequest

type PaginationRequest struct {
	Page    int
	MaxSize int
	Filter  func(*gorm.DB) *gorm.DB
}

Jump to

Keyboard shortcuts

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