resolver

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package resolver provides URL resolution functionality for the goose client

Package resolver provides URL resolution functionality for the goose client

Package resolver provides URL resolution functionality for the goose client

Package resolver provides URL resolution functionality for the goose client

Package resolver provides URL resolution functionality for the goose client

Index

Constants

This section is empty.

Variables

View Source
var DefaultHttpScheme = "http"

DefaultHttpScheme is the default HTTP scheme used by the DefaultResolver

Functions

func RegisterResolver

func RegisterResolver(resolver Resolver)

RegisterResolver registers a resolver for its scheme This allows the resolver to be automatically used when resolving URLs with matching schemes Parameters:

  • resolver: Resolver to register

func Resolve

func Resolve(ctx context.Context, resolver Resolver, targetStr string) (*url.URL, error)

Resolve resolves a target URL string using the appropriate resolver It first tries to use the provided resolver if its scheme matches the target, otherwise it looks up a registered resolver by the target's scheme Parameters:

  • ctx: Context for the resolution operation
  • resolver: Optional resolver to try first (can be nil)
  • targetStr: Target URL string to resolve

Returns:

  • *url.URL: Resolved URL
  • error: Error if parsing or resolution fails

Types

type DefaultResolver

type DefaultResolver struct {
	HttpScheme string // Custom HTTP scheme to use instead of default
}

DefaultResolver is a resolver that handles URLs with empty schemes

func (DefaultResolver) Resolve

func (r DefaultResolver) Resolve(ctx context.Context, target *url.URL) (*url.URL, error)

Resolve resolves a target URL by copying its components and setting the scheme Parameters:

  • ctx: Context for the resolution operation
  • target: Target URL to resolve

Returns:

  • *url.URL: Resolved URL with scheme set
  • error: Error if the target scheme doesn't match this resolver's scheme

func (DefaultResolver) Scheme

func (r DefaultResolver) Scheme() string

Scheme returns the scheme that this resolver handles (empty string for default resolver) Returns:

  • string: Empty string, indicating this resolver handles URLs with no scheme

type HttpResolver

type HttpResolver struct{}

HttpResolver is a resolver that handles URLs with "http" scheme

func (HttpResolver) Resolve

func (r HttpResolver) Resolve(ctx context.Context, target *url.URL) (*url.URL, error)

Resolve resolves an HTTP target URL by copying all its components Parameters:

  • ctx: Context for the resolution operation
  • target: Target URL with "http" scheme to resolve

Returns:

  • *url.URL: Resolved URL with all components copied from target
  • error: Error if the target scheme is not "http" (case-insensitive)

func (HttpResolver) Scheme

func (r HttpResolver) Scheme() string

Scheme returns the scheme that this resolver handles Returns:

  • string: "http", indicating this resolver handles URLs with "http" scheme

type HttpsResolver

type HttpsResolver struct{}

HttpsResolver is a resolver that handles URLs with "https" scheme

func (HttpsResolver) Resolve

func (r HttpsResolver) Resolve(ctx context.Context, target *url.URL) (*url.URL, error)

Resolve resolves an HTTPS target URL by copying all its components Parameters:

  • ctx: Context for the resolution operation
  • target: Target URL with "https" scheme to resolve

Returns:

  • *url.URL: Resolved URL with all components copied from target
  • error: Error if the target scheme is not "https" (case-insensitive)

func (HttpsResolver) Scheme

func (r HttpsResolver) Scheme() string

Scheme returns the scheme that this resolver handles Returns:

  • string: "https", indicating this resolver handles URLs with "https" scheme

type Resolver

type Resolver interface {
	// Resolve takes a target URL and returns a resolved URL
	// Parameters:
	//   - ctx: Context for the resolution operation
	//   - target: Target URL to resolve
	// Returns:
	//   - *url.URL: Resolved URL
	//   - error: Error if resolution fails
	Resolve(ctx context.Context, target *url.URL) (*url.URL, error)

	// Scheme returns the URL scheme this resolver handles
	// Returns:
	//   - string: URL scheme (e.g., "http", "https", "")
	Scheme() string
}

Resolver is an interface for resolving target URLs to actual URLs Implementations handle different URL schemes and resolve them appropriately

type ResolverError

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

ResolverError represents an error that occurs when a URL scheme is not supported by any registered resolver

func (*ResolverError) Error

func (e *ResolverError) Error() string

Error returns a formatted error message indicating which scheme is not supported Returns:

  • string: Error message in the format "resolver: scheme <scheme> is not supported"

func (*ResolverError) Target

func (e *ResolverError) Target() *url.URL

Target returns the target URL that caused the resolver error Returns:

  • *url.URL: The URL that could not be resolved due to unsupported scheme

Jump to

Keyboard shortcuts

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