proxy

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(w http.ResponseWriter, r *http.Request, errMsg string, printLogs bool)

HandleError ...

func HandleGRPCError

func HandleGRPCError(w http.ResponseWriter, ct, errMsg string)

HandleGRPCError ...

func HandleHTTPError

func HandleHTTPError(w http.ResponseWriter, errMsg string)

HandleHTTPError ...

func Handler

func Handler(config *config.ProxyConfig, cli *http.Client) http.HandlerFunc

Handler handles the proxy requests

func NewCustomeRsWriter

func NewCustomeRsWriter() http.ResponseWriter

NewCustomeRsWriter ...

func NewProxyFromFile

func NewProxyFromFile(file string) (*config.ProxyConfig, error)

NewProxyFromFile ...

func NewProxyGRPC

func NewProxyGRPC(host string, port string) *config.ProxyConfig

NewProxyGRPC ...

func PrintLog

func PrintLog(t time.Time, reqSize int, resSize int, r *http.Request, compact bool)

PrintLog prints in stout basic information about the request and response

Types

type CustomResponseWriter

type CustomResponseWriter struct {
	Headers http.Header
	Status  int
	Body    []byte
}

CustomResponseWriter implements http.ResponseWriter

func (*CustomResponseWriter) Header

func (w *CustomResponseWriter) Header() http.Header

Header ...

func (*CustomResponseWriter) Write

func (w *CustomResponseWriter) Write(b []byte) (int, error)

Write ...

func (*CustomResponseWriter) WriteHeader

func (w *CustomResponseWriter) WriteHeader(s int)

WriteHeader ...

type FakeReader

type FakeReader struct{}

FakeReader feake reader implements the io.Reader and io.ReadCloser

func (*FakeReader) Close

func (r *FakeReader) Close() error

Close ...

func (*FakeReader) Read

func (r *FakeReader) Read(p []byte) (n int, err error)

Read ...

Jump to

Keyboard shortcuts

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