rewrite

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidHost = errors.New("rewrite host has invalid type")
View Source
var RewriteHostKey rewriteKeyType = "__uncors_rewrite_host"

RewriteHostKey is a key used to store host rewriting configuration in the request context.

Functions

func GetRewriteHost

func GetRewriteHost(request *contracts.Request) (string, error)

GetRewriteHost extracts the rewrite host value from the request context. It returns the host string and any error encountered during extraction. If no host value is found in the context, it returns an empty string and nil error. If the value exists but is not a string, it returns ErrInvalidHost.

func IsRewriteRequest

func IsRewriteRequest(request *contracts.Request) bool

IsRewriteRequest checks if the provided request contains a rewrite host in its context. It returns true if the request has a rewrite host value set under RewriteHostKey, false otherwise.

Types

type Middleware

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

func NewMiddleware

func NewMiddleware(options ...MiddlewareOption) *Middleware

func (*Middleware) Wrap

type MiddlewareOption

type MiddlewareOption = func(*Middleware)

func WithRewritingOptions

func WithRewritingOptions(rewrite config.RewritingOption) MiddlewareOption

Jump to

Keyboard shortcuts

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