cproxy

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const AppName = "CProxy"

AppName - name of this application

View Source
const DefaultConfigFilePath = "cproxy.json"

DefaultConfigFilePath - default path to config file

View Source
const ProxyTypeDummy = "dummy"

ProxyTypeDummy - denotes dummy test proxy

View Source
const ProxyTypeFCGI = "fcgi"

ProxyTypeFCGI - denotes FastCGI proxy

View Source
const ProxyTypeHTTP = "http"

ProxyTypeHTTP - denotes HTTP proxy

View Source
const VersionNo = 1

VersionNo - current version of this application

Variables

This section is empty.

Functions

func BackendFetch

func BackendFetch(req *http.Request, config *Config) (*http.Response, error)

BackendFetch - fetch content from backend

func GetFCGIEnvVars

func GetFCGIEnvVars(req *http.Request, config *Config) map[string]string

GetFCGIEnvVars - retrieve FCGI env vars

func GetListener

func GetListener(config *Config) (net.Listener, error)

GetListener - get listener for incomming requests

func HTTPResponseFromBytes

func HTTPResponseFromBytes(b []byte) (*http.Response, error)

HTTPResponseFromBytes - convert bytes to http response

func HTTPResponseToBytes

func HTTPResponseToBytes(r *http.Response) ([]byte, error)

HTTPResponseToBytes - convert http response to bytes

func HandleRequest

func HandleRequest(req *http.Request, config *Config, exts *[]Extension) (*http.Response, error)

HandleRequest - handle a request

func RenderErrorPage

func RenderErrorPage(w http.ResponseWriter, r *http.Request, err error)

RenderErrorPage - render an error page

func UnloadExtensions

func UnloadExtensions(exts *[]Extension)

UnloadExtensions - unload all extensions

Types

type Config

type Config struct {
	ProxyType  string `json:"proxy_type"`
	Listen     string `json:"listen"`  // 8081, /app/listen.sock
	Backend    string `json:"backend"` // 127.0.0.1:9000, /app/run.sock, https://www.example.com
	Extensions struct {
		Path    string                     `json:"path"`
		Enabled []string                   `json:"enabled"`
		Config  map[string]json.RawMessage `json:"config"`
	} `json:"extensions"`
}

Config - app configuration struct

func GetDefaultConfig

func GetDefaultConfig() Config

GetDefaultConfig - get default configuration values

func LoadConfigFile

func LoadConfigFile(configFilePath string) Config

LoadConfigFile - load configuration from file

type Extension

type Extension struct {
	Name       string
	OnUnload   func()
	OnRequest  func(req *http.Request) (*http.Response, error)
	OnResponse func(resp *http.Response) (*http.Response, error)
}

Extension - cproxy extension data

func LoadExtensions

func LoadExtensions(config *Config, subRequestCallback func(req *http.Request) (*http.Response, error)) ([]Extension, error)

LoadExtensions - load extensions and initalize

Jump to

Keyboard shortcuts

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