router

package
v0.1.777 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
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}`
	// PKey is the default key for path parameters.
	PKey = "_p"
	// RKey is the default ressource key.
	RKey = "_r"
	// SvcKey is the default service key.
	SvcKey = "_s"
	// PathActions is the default path for actions.
	PathActions = "actions"
)

Variables

This section is empty.

Functions

This section is empty.

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 WithDashboard added in v0.1.11

func WithDashboard() ClientOption

func WithPathKey

func WithPathKey(x string) ClientOption

func WithRessourceKey

func WithRessourceKey(x string) ClientOption

func WithSvcKey added in v0.1.198

func WithSvcKey(x string) ClientOption

type ClientOptions

type ClientOptions struct {
	Dashboard    bool
	SvcKey       string
	RessourceKey string
	PathKey      string
}

func ApplyClientOptions

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

type DefaultTool added in v0.1.11

type DefaultTool struct {
	T *contract.Tool[Client]
}

func NewTool

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

func (*DefaultTool) AttachServer added in v0.1.26

func (d *DefaultTool) AttachServer(ctx context.Context, s contract.ServerOperator) error

AttachServer attaches the server operator to the router.

func (*DefaultTool) Mount added in v0.1.11

func (d *DefaultTool) Mount(ctx context.Context, r []*contract.Route) error

Mount mounts the routes to the router.

func (*DefaultTool) ParsePath added in v0.1.27

func (d *DefaultTool) ParsePath(ctx context.Context, r *http.Request, re *regexp.Regexp) (map[string]string, error)

ParsePath extracts path parameters using the route regex.

func (*DefaultTool) ParseQuery added in v0.1.27

func (d *DefaultTool) ParseQuery(ctx context.Context, r *http.Request) (map[string][]string, error)

ParseQuery returns query parameters from the request.

func (*DefaultTool) RKey added in v0.1.198

func (d *DefaultTool) RKey(ctx context.Context) (string, error)

RKey returns the ressource key configured for the router.

func (*DefaultTool) Run added in v0.1.11

func (d *DefaultTool) Run(ctx context.Context) error

Run starts the router server.

func (*DefaultTool) Stop added in v0.1.11

func (d *DefaultTool) Stop(ctx context.Context) error

Stop gracefully shuts down the router server.

func (*DefaultTool) SvcKey added in v0.1.198

func (d *DefaultTool) SvcKey(ctx context.Context) (string, error)

SvcKey returns the service key configured for the router.

func (*DefaultTool) Vars added in v0.1.11

func (d *DefaultTool) Vars(ctx context.Context) (*config.Vars, error)

Vars extracts routing variables from context.

type Pattern

type Pattern = string

Pattern represents a regex pattern string.

type Tool added in v0.1.245

type Tool interface {
	Client
}

Jump to

Keyboard shortcuts

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