urlhandler

package
v0.0.3-beta.8 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotVerifyHost = fmt.Errorf("not verify host")

ErrorNotVerifyHost is returned when URL host verification fails in strict mode.

Functions

This section is empty.

Types

type Handler

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

Handler provides URL generation and key extraction for storage backends. It manages the relationship between storage keys and their public URLs.

func NewHandler

func NewHandler(public string) (*Handler, error)

NewHandler creates a new URL handler with the specified public base URL. The public base URL is used to generate full URLs for storage keys.

func (*Handler) ExtractKeyFromURL

func (n *Handler) ExtractKeyFromURL(uri string) string

ExtractKeyFromURL extracts the storage key from a URL with strict host verification enabled. Returns an empty string if host verification fails or if there's a parsing error.

func (*Handler) ExtractKeyFromURLWithMode

func (n *Handler) ExtractKeyFromURLWithMode(uri string, strict bool) (string, error)

ExtractKeyFromURLWithMode extracts the storage key from a URL with optional host verification. When strict is true, it validates that the URL belongs to the configured host. Returns an error if strict mode validation fails.

func (*Handler) GenerateURL

func (n *Handler) GenerateURL(key string) string

GenerateURL creates a public URL for the given storage key. If the key already contains a full URL, it returns the key unchanged.

func (*Handler) GenerateURLs

func (n *Handler) GenerateURLs(keys []string) []string

GenerateURLs creates public URLs for multiple storage keys in batch.

Jump to

Keyboard shortcuts

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