router

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHTTPMethod                = errors.New("invalid HTTP method")
	ErrVarsNotFoundInContext            = errors.New("vars not found in context")
	ErrMissingMiddleware                = errors.New("missing middleware")
	ErrMissingPathKey                   = errors.New("missing path key")
	ErrMissingRessourceKey              = errors.New("missing ressource key")
	ErrPathKeyAndRessourceKeyAreTheSame = errors.New("path key and ressource key are the same")
	ErrMissingRoute                     = errors.New("missing route")
	ErrLimiterNotEnabledWithWeight      = errors.New("only unlimited weight can be used if limiter is not enabled")
	ErrDuplicateEntry                   = errors.New("duplicate route entry")
)

Functions

func NewTool

func NewTool(c Client, opts contract.ToolOptions[Client]) *defaultTool

Types

type Client

type Client interface {
	contract.RouterOperator
}

func NewClient

func NewClient(d Dependencies, opts ClientOptions) (Client, error)

type ClientOption

type ClientOption func(*ClientOptions)

func WithPathKey

func WithPathKey(key string) ClientOption

func WithRessourceKey

func WithRessourceKey(key string) ClientOption

type ClientOptions

type ClientOptions struct {
	PathKey      string
	RessourceKey string
}

func ApplyClientOptions

func ApplyClientOptions(opts *ClientOptions, modifiers ...ClientOption) ClientOptions

type Pattern

type Pattern = string

Pattern represents a regex pattern string.

const (
	// PatID matches numeric path parameters (e.g., user ID).
	PatID Pattern = `[0-9]+`
	// PatName matches alphabetic characters only (uppercase or lowercase).
	PatName Pattern = `[a-zA-Z]+`
	// PatWord matches any word-like token (alphanumeric and underscore).
	PatWord Pattern = `\w+`
	// PatWordCI matches word-like tokens, case-insensitive.
	PatWordCI Pattern = `(?i)\w+`
	// PatEmail matches a basic email address format.
	PatEmail Pattern = `[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`
	// PatOID matches a 24-character hexadecimal string (MongoDB ObjectID).
	PatOID Pattern = `[0-9a-fA-F]{24}`
	// PatFile matches any file name with an extension.
	PatFile Pattern = `.*\.[^/]*$`
	// PatUUID matches a UUID string in standard 8-4-4-4-12 format.
	PatUUID Pattern = `[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`
)

Jump to

Keyboard shortcuts

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