http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(_ context.Context) (*Client, error)

func (*Client) Do

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

Do runs a request with the http client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) (resp *http.Response, err error)

Get calls http.Get with expected http User-Agent.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

NewRequest calls http.NewRequest with expected http User-Agent.

func (*Client) Transport

func (c *Client) Transport() (transport http.RoundTripper)

type Module

type Module interface {
	Name() string
	Route(s *Server) error
	SetServer(s *Server)
}

Module represents a module that can be added to a http server

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

ResponseWriter is a ResponseWriter that keeps track of status and body size

func NewResponseWriter

func NewResponseWriter(w http.ResponseWriter) *ResponseWriter

NewResponseWriter creates a new ResponseWriter

func (*ResponseWriter) BodyLength

func (r *ResponseWriter) BodyLength() int

BodyLength returns the response body length

func (*ResponseWriter) Status

func (r *ResponseWriter) Status() int

Status returns the status code of the response

func (*ResponseWriter) Write

func (r *ResponseWriter) Write(b []byte) (int, error)

Write to the response writer, also updating body length

func (*ResponseWriter) WriteHeader

func (r *ResponseWriter) WriteHeader(status int)

WriteHeader sets the status of the response

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a http 2 web server

func NewServer

func NewServer(_ context.Context, m metrics.Collector) (*Server, error)

NewServer creates a new http web server

func (*Server) HandleFunc

func (s *Server) HandleFunc(path string, f func(http.ResponseWriter, *http.Request)) *mux.Route

HandleFunc attaches a function to a path

func (*Server) MiddlewareMetrics

func (s *Server) MiddlewareMetrics(next http.Handler) http.Handler

func (*Server) PathPrefix

func (s *Server) PathPrefix(path string) *mux.Route

PathPrefix attaches a new route url path prefix

func (*Server) Start

func (s *Server) Start() error

Start starts the web server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop shuts down the web server

func (*Server) WrapInMiddlewares

func (s *Server) WrapInMiddlewares(h http.Handler) http.Handler

WrapInMiddlewares wraps an http.Handler in the server's middleware.

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport adds the expected http User-Agent to any request.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes the default http.Transport with expected http User-Agent.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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