rproxy

package
v0.0.0-...-4167999 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRateLimiter

func GetRateLimiter(ip string) *rate.Limiter

GetRateLimiter retrieves a rate limiter for a given IP address, creating one if it doesn't exist.

func NewProxy

func NewProxy(rhost string, rport int, logger *zap.Logger) (*proxy, error)

NewProxy initializes and returns a new reverse proxy pointing to the given host and port. It takes a remote host address, port, and a logger as its arguments.

func ProxyRequestHandler

func ProxyRequestHandler(proxy *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request)

ProxyRequestHandler returns a function suitable for use as an http.HandlerFunc. The returned function will use the provided ReverseProxy to proxy HTTP requests.

func RateLimiterMiddleware

func RateLimiterMiddleware(p *proxy) http.Handler

rateLimiterMiddleware checks if the incoming request exceeds the rate limit. If it does, the middleware responds with a "Too Many Requests" status and stops further processing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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