urltrie

package
v0.0.0-...-f9eaf4d Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHook

func RegisterHook(hook Hook)

RegisterHook register url & hook to trie.

func RunHook

func RunHook() gin.HandlerFunc

RunHook enable hook for interceptor.

Types

type Hook

type Hook interface {
	// Register with url pattern
	// Support * wildcard, you can use it like this:
	// /api/v1/*, and the url like /api/v1/123 will be matched
	//
	// Now we support multi urls.
	Patterns() []string

	// Priority will set the priority of the hook
	Priority() int64

	// Hooks
	// BeforeRun will be called before controller, you can do something here
	BeforeRun(c *gin.Context)
	// AfterRun will be called after controller, you can do something here
	AfterRun(c *gin.Context)
}

Hook for interceptor.

type Trie

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

Trie is a tree for url.

func NewTrie

func NewTrie() *Trie

NewTrie returns a new Trie.

func (*Trie) InsertBatch

func (t *Trie) InsertBatch(urls []string, hooks ...Hook)

InsertBatch insert urls with hooks.

func (*Trie) Match

func (t *Trie) Match(url string) ([]Hook, bool)

Match match url with hooks.

Jump to

Keyboard shortcuts

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