urldescribe

package module
v0.0.0-...-7921845 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: Apache-2.0 Imports: 8 Imported by: 1

README

urldescribe

Go library to describe URLs. Essentially just returns whatever is in the

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHost      = errors.New("URL needs to have a host")
	ErrLocalhost        = errors.New("URL cannot point to localhost")
	ErrResponseTooLarge = errors.New("response body is too large")
	ErrNotHTML          = errors.New("response is not text/html")
)

Functions

func DescribeURL

func DescribeURL(ctx context.Context, rawurl string, opts ...Option) (string, error)

DescribeURL takes an URL and returns its description (ie. its <title> tag)

Types

type Config

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

Config holds the configuration for URL description

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

type Option

type Option func(*Config)

Option is a functional option for configuring the URL describer

func WithMaxLength

func WithMaxLength(n int) Option

WithMaxLength sets the maximum length for returned descriptions

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the HTTP client timeout

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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