route

package
v0.92.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package route provides HTTP route registration and discovery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorize

func Authorize(authLevel AuthLevel, handler fiber.Handler) fiber.Handler

func CheckAccessToken

func CheckAccessToken(accessToken string) (uid types.Uid, isValid bool)

func ErrorResponse

func ErrorResponse(ctx fiber.Ctx, text string) error

func GetAccessToken

func GetAccessToken(req *http.Request) string

GetAccessToken extracts the API key from an HTTP request.

func GetIntParam

func GetIntParam(ctx fiber.Ctx, name string) int64

func GetParam added in v0.92.0

func GetParam(ctx fiber.Ctx) types.KV

func GetScopes added in v0.92.0

func GetScopes(ctx fiber.Ctx) []string

func GetTopic

func GetTopic(ctx fiber.Ctx) string

func GetUid

func GetUid(ctx fiber.Ctx) types.Uid

func RequireScope added in v0.92.0

func RequireScope(scope string, handler fiber.Handler) fiber.Handler

func ScopeHandler added in v0.92.0

func ScopeHandler(ctx fiber.Ctx, scope string) bool

func SetAuditor added in v0.92.0

func SetAuditor(a audit.Auditor)

SetAuditor sets the global auditor used for auth event recording.

func WebService

func WebService(app *fiber.App, group string, rs ...*Router)

Types

type AuthLevel added in v0.29.3

type AuthLevel int
const (
	NoAuth AuthLevel = 1
)

type Option

type Option func(r *Router)

func WithNotAuth

func WithNotAuth() Option

type RequestContext added in v0.92.0

type RequestContext struct {
	UID    types.Uid
	Topic  string
	Param  types.KV
	Scopes []string
}

RequestContext is a typed struct stored in fiber.Locals after authorization. It carries the authenticated user identity, request metadata, and scopes.

func GetRequestContext added in v0.92.0

func GetRequestContext(ctx fiber.Ctx) *RequestContext

GetRequestContext returns the typed RequestContext from fiber.Locals. Returns nil if the request was not authorized.

type Router

type Router struct {
	Method        string
	Path          string
	Function      fiber.Handler
	Documentation string
	AuthLevel     AuthLevel
}

func Route

func Route(method, path string, function fiber.Handler, options ...Option) *Router

Jump to

Keyboard shortcuts

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