path

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualLocation

func EqualLocation(a, b Location) bool

EqualLocation reports whether a and b encode the same path and query.

Types

type Adapter

type Adapter[M any] interface {
	AnyAdapter
	Decode(any) (*M, bool)
	Encode(model *M) (Location, error)
	Assert(any) (*M, bool)
}

func NewAdapter

func NewAdapter[M any]() (Adapter[M], error)

func NewLocationAdapter

func NewLocationAdapter() Adapter[Location]

NewLocationAdapter returns an adapter that treats Location as a path model.

type Adapters

type Adapters []AnyAdapter

func (*Adapters) Add

func (as *Adapters) Add(a AnyAdapter)

func (Adapters) Encode

func (as Adapters) Encode(v any) (Location, error)

type AnyAdapter

type AnyAdapter interface {
	EncodeAny(any) (Location, error, bool)
}

type HookMatch

type HookMatch struct {
	Instance string
	Door     uint64
	Hook     uint64
	Track    uint64
}

type Location

type Location struct {
	// Query holds the decoded query parameters.
	Query url.Values
	// Segments holds the decoded path segments without leading or trailing
	// slashes.
	Segments []string
}

Location is a parsed or generated URL path plus query string.

func NewLocationFromEscapedURI

func NewLocationFromEscapedURI(s string) (Location, error)

NewLocationFromEscapedURI parses s into a Location.

func NewLocationFromURL

func NewLocationFromURL(u *url.URL) (Location, error)

NewLocationFromURL decodes u into a Location.

func (Location) Path

func (l Location) Path() string

Path returns the escaped path portion of l without the query string.

func (Location) String

func (l Location) String() string

String returns l encoded as `/<segments>?<query>`.

type Match

type Match struct {
	// contains filtered or unexported fields
}

func (Match) Hook

func (m Match) Hook() (HookMatch, bool)

func (Match) Resource

func (m Match) Resource() (id string, ok bool)

func (Match) Sync

func (m Match) Sync() (instanceID string, ok bool)

func (Match) Undo

func (m Match) Undo() (UndoPath, bool)

type PathMaker

type PathMaker struct {
	// contains filtered or unexported fields
}

func NewPathMaker

func NewPathMaker(serverID string) PathMaker

func (PathMaker) Hook

func (pm PathMaker) Hook(instanceId string, doorId uint64, hookId uint64, name string) string

func (PathMaker) ID

func (pm PathMaker) ID() string

func (PathMaker) Match

func (pm PathMaker) Match(r *http.Request) (Match, bool)

func (PathMaker) Prefix

func (pm PathMaker) Prefix() string

func (PathMaker) Resource

func (pm PathMaker) Resource(r *resources.Resource, name string) string

type UndoPath

type UndoPath struct {
	Instance string
	Location Location
}

Jump to

Keyboard shortcuts

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