router

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package router provides URL path matching and building utilities. It supports path parameters (e.g., :id) and wildcard matching (*).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPath

func BuildPath(pattern string, params map[string]string) string

BuildPath substitutes parameter placeholders in a pattern with values from params. Example: BuildPath("/users/:id", map[string]string{"id": "42"}) returns "/users/42"

func FunctionPath

func FunctionPath(functionID, pattern string, params map[string]string) string

FunctionPath builds a full path for a function with the given pattern and parameters. Returns "/fn/{functionID}{path}"

func FunctionURL

func FunctionURL(baseURL, functionID, pattern string, params map[string]string) string

FunctionURL builds a full URL for a function with the given pattern and parameters. Returns "{baseURL}/fn/{functionID}{path}"

func SplitPath

func SplitPath(path string) []string

SplitPath splits a path into non-empty segments.

Types

type MatchResult

type MatchResult struct {
	Matched bool
	Params  map[string]string
}

MatchResult contains the result of a path match operation.

func Match

func Match(path, pattern string) MatchResult

Match checks if a path matches a pattern and returns match result with extracted parameters. Pattern syntax:

  • :name captures a path segment into params["name"]
  • * at the end matches any remaining path segments

Jump to

Keyboard shortcuts

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