reverseproxy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package reverseproxy allows instance a simple reverse proxy with capacity to implement many interceptors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configurer

type Configurer interface {

	// Origin allows set the endpoint backend url.
	Origin(address string) error

	// Public allows set the endpoint frontend url.
	Public(address string) error

	// AddInterceptor allows loading a new interceptor that the proxy must be execute by each request.
	//
	// Receives a name to identify the interceptor loaded.
	AddInterceptor(name string, interceptor interceptor.Interceptor) error
}

Configurer defines the available options to configure a new instance of reverseproxy.ReverseProxy.

type ReverseProxy

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

ReverseProxy execute a httputil.ReverseProxy and manage the interceptors configured.

func New

func New(options ...func(Configurer) error) (*ReverseProxy, error)

New returns a new reverseproxy.ReverseProxy instace configured.

Receives a list of options callback with the configurations to apply.

func (*ReverseProxy) Run

func (rp *ReverseProxy) Run() error

Run starts to lisent and serve the reverse proxy

func (*ReverseProxy) ServeHTTP

func (rp *ReverseProxy) ServeHTTP(response http.ResponseWriter, request *http.Request) error

ServeHTTP implements http.Handler interface. It allows execute a request parse manually.

Receives the request data that the reverse proxy handle to apply the correspondent redirection.

Jump to

Keyboard shortcuts

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