proxy

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

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

Proxy represents a reverse proxy server with logging, page management, and request handling capabilities.

func NewProxy

func NewProxy(conf config.StaticPagesConfig) *Proxy

NewProxy initializes and returns a new Proxy instance configured with the provided logger and page definitions.

func (*Proxy) Director

func (p *Proxy) Director(req *http.Request)

Director modifies the incoming HTTP request to route it to the appropriate backend server based on the request host and path.

func (*Proxy) ErrorHandler

func (p *Proxy) ErrorHandler(w http.ResponseWriter, req *http.Request, err error)

ErrorHandler handles errors during request processing by logging the error and responding with the appropriate HTTP status code.

func (*Proxy) ModifyResponse

func (p *Proxy) ModifyResponse(r *http.Response) error

ModifyResponse inspects and logs HTTP responses with a status code of 300 or higher, returning nil or an error.

func (*Proxy) Serve

func (p *Proxy) Serve(addr string) humane.Error

Serve starts the reverse proxy server on the specified address and logs its startup state. It returns a humane.Error if the server fails to start.

func (*Proxy) ServeAsync

func (p *Proxy) ServeAsync(addr string)

ServeAsync starts the reverse proxy server on the specified address and logs the startup message. It runs the server in a separate goroutine and handles failure to start by logging a fatal error. It Panics when the Proxy Server could not start

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP handles incoming HTTP requests and proxies them to the configured backend, allowing only GET requests.

func (*Proxy) Shutdown

func (p *Proxy) Shutdown() humane.Error

Shutdown gracefully stops the proxy server if it is running, releasing any resources and handling in-progress requests. It returns a humane.Error if the server fails to stop.

Jump to

Keyboard shortcuts

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