common

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProxyError

func ProxyError(w http.ResponseWriter, err error)

ProxyError log error and return a HTTP 526 error with the message

func ProxyErrorf

func ProxyErrorf(w http.ResponseWriter, format string, args ...interface{})

ProxyErrorf log error and return a HTTP 526 error with the message

func UnserializeHTTPRequest

func UnserializeHTTPRequest(req *HTTPRequest) (r *http.Request, err error)

UnserializeHTTPRequest create a new http.Request from a HTTPRequest

Types

type HTTPRequest

type HTTPRequest struct {
	Method        string
	URL           string
	Header        map[string][]string
	ContentLength int64
	WS            bool
}

HTTPRequest is a serializable version of http.Request ( with only usefull fields )

func SerializeHTTPRequest

func SerializeHTTPRequest(req *http.Request) (r *HTTPRequest)

SerializeHTTPRequest create a new HTTPRequest from a http.Request

type HTTPResponse

type HTTPResponse struct {
	StatusCode    int
	Header        http.Header
	ContentLength int64
}

HTTPResponse is a serializable version of http.Response ( with only useful fields )

func NewHTTPResponse

func NewHTTPResponse() (r *HTTPResponse)

NewHTTPResponse creates a new HTTPResponse

func SerializeHTTPResponse

func SerializeHTTPResponse(resp *http.Response) *HTTPResponse

SerializeHTTPResponse create a new HTTPResponse from a http.Response

type Rule

type Rule struct {
	Method  string
	URL     string
	Headers map[string]string
	// contains filtered or unexported fields
}

Rule match HTTP requests to allow / deny access

func NewRule

func NewRule(method string, url string, headers map[string]string) (rule *Rule, err error)

NewRule creates a new Rule

func (*Rule) Compile

func (rule *Rule) Compile() (err error)

Compile the regular expressions

func (*Rule) Match

func (rule *Rule) Match(req *http.Request) bool

Match returns true if the http.Request matches the Rule

func (*Rule) String

func (rule *Rule) String() string

Jump to

Keyboard shortcuts

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