veilprox

package module
v0.0.0-...-38d3991 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Author - gentcod (Oyefule Oluwatayo)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// BackendUrl is the actual backend server E.g: http://localhost:5000
	BackendUrl string

	// defaultUrl is the unmapped endpoints or default redirect url for routes that do not exist,
	// for example "/not-found"
	DefaultRoute string

	// Timeout serves as proxy transport timeout
	Timeout time.Duration

	// MaxRoutes specifies the maximum number of routes allowed.
	MaxRoutes int

	// EnableMetrics allows proxy metrics tracking.
	EnableMetrics bool

	// Debug enables debug logging
	Debug bool

	// Logger is yout custom logger
	Logger *log.Logger
}

Config holds configuration options for the proxy router.

func DefaultConfig

func DefaultConfig(backendUrl string) *Config

DefaultConfig returns a configuration with sensible defaults.

type ManagerConfig

type ManagerConfig struct {
	EnableMetrics bool
	ReadOnly      bool
}

ManagerConfig holds configuration for the management endpoint

type ProxyRouter

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

ProxyRouter holds the reverse proxy and routing map.

func New

func New(config *Config, routeMap map[string]string) (*ProxyRouter, error)

New creates a proxy masker that maps incoming paths to internal targets

func (*ProxyRouter) AddRoute

func (p *ProxyRouter) AddRoute(masked, real string) error

AddRoute adds or updates a masked route

func (*ProxyRouter) GetMetrics

func (p *ProxyRouter) GetMetrics() map[string]interface{}

GetMetrics returns current proxy metrics

func (*ProxyRouter) GetProxy

func (p *ProxyRouter) GetProxy() *httputil.ReverseProxy

func (*ProxyRouter) GetProxyConfig

func (p *ProxyRouter) GetProxyConfig() *Config

func (*ProxyRouter) GetProxyMetrics

func (p *ProxyRouter) GetProxyMetrics() *pkg.Metrics

func (*ProxyRouter) GetProxyRoute

func (p *ProxyRouter) GetProxyRoute() map[string]string

func (*ProxyRouter) ListRoutes

func (p *ProxyRouter) ListRoutes() map[string]string

ListRoutes returns a copy of the current route mappings

func (*ProxyRouter) ManagerHandler

func (p *ProxyRouter) ManagerHandler(config *ManagerConfig) http.Handler

ManagerHandler provides HTTP endpoints for managing routes dynamically it provides the functionality of modifying routes during runtime without having to restart the server everytime This should be protected by your own authentication middleware.

func (*ProxyRouter) ModifyRoute

func (p *ProxyRouter) ModifyRoute(mask, real string) error

ModifyRoute modifies a masked route

func (*ProxyRouter) RemoveRoute

func (p *ProxyRouter) RemoveRoute(masked string) error

RemoveRoute deletes a route mapping

func (*ProxyRouter) Route

func (p *ProxyRouter) Route(debug bool) http.HandlerFunc

Route returns an http.HandlerFunc middleware for use in standard http or frameworks

func (*ProxyRouter) RouteExists

func (p *ProxyRouter) RouteExists(masked string) bool

RouteExists checks if a masked route exists

func (*ProxyRouter) ServeHTTP

func (p *ProxyRouter) ServeHTTP(w http.ResponseWriter, r *http.Request, debug bool)

ServeHTTP allows ProxyRouter to be used directly as an http.Handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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