http

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ShutdownTimeout = 1 * time.Second

ShutdownTimeout is the time given for outstanding requests to finish before shutdown.

Variables

This section is empty.

Functions

func AllToEmpty

func AllToEmpty(s string) string

AllToEmpty convert `-` which means all to empty.

func EmptyToAll

func EmptyToAll(s string) string

EmptyToAll covert empty to `-` which mean all.

func Error

func Error(w http.ResponseWriter, req *http.Request, err error)

Error prints & optionally logs an error message.

func ErrorStatusCode

func ErrorStatusCode(code string) int

ErrorStatusCode returns the associated HTTP status code for a BatProxy error code.

func FromErrorStatusCode

func FromErrorStatusCode(code int) string

FromErrorStatusCode returns the associated BatProxy code for an HTTP status code.

Types

type Client

type Client struct {
	URL string
	// contains filtered or unexported fields
}

Client represents an HTTP client.

func NewClient

func NewClient(u string) (*Client, error)

NewClient returns a new instance of Client.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents a JSON structure for error output.

type ProxyService

type ProxyService struct {
	Client *Client
}

func NewProxyService

func NewProxyService(client *Client) *ProxyService

func (*ProxyService) CreateProxy

func (s *ProxyService) CreateProxy(ctx context.Context, proxy *batproxy.Proxy, opts batproxy.CreateProxyOptions) error

func (*ProxyService) DeleteProxy

func (s *ProxyService) DeleteProxy(ctx context.Context, proxyID string) error

func (*ProxyService) ListProxies

func (*ProxyService) UpdateProxy

func (s *ProxyService) UpdateProxy(req *restful.Request, res *restful.Response)

type Server

type Server struct {
	ProxyService batproxy.ProxyService
	// contains filtered or unexported fields
}

func NewServer

func NewServer(reverseProxyAddr, managerAddr string, l *slog.Logger) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) Open

func (s *Server) Open() (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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