common

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeserializeHTTPRequest added in v0.19.2

func DeserializeHTTPRequest(jsonRequest []byte) (r *http.Request, err error)

DeserializeHTTPRequest create a new http.Request from a HTTPRequest

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

Types

type HTTPRequest

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

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
	Body          []byte
}

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 *httptest.ResponseRecorder) *HTTPResponse

SerializeHTTPResponse create a new HTTPResponse from a http.Response

Jump to

Keyboard shortcuts

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