http

package
v1.233.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReadAll for HTTP.
	ErrReadAll = errors.New("invalid body read")

	// ErrUnmarshal for HTTP.
	ErrUnmarshal = errors.New("invalid unmarshal")

	// ErrHandle for HTTP.
	ErrHandle = errors.New("invalid handle")

	// ErrMarshal for HTTP.
	ErrMarshal = errors.New("invalid marshal")
)

Functions

func Code added in v1.231.0

func Code(err error) int

Code from the error, otherwise 500.

func Error added in v1.231.0

func Error(code int, msg string) error

Error representing code and msg.

func Handle added in v1.218.0

func Handle[Req any, Res any](path string, handler Handler[Req, Res])

Handler for HTTP.

func IsError added in v1.232.0

func IsError(err error) bool

IsError verifies if the package created this error.

func Register added in v1.222.0

func Register(mu *http.ServeMux, ma *marshaller.Map)

Register for HTTP.

Types

type Client added in v1.229.0

type Client[Req any, Res any] struct {
	// contains filtered or unexported fields
}

Client for HTTP.

func NewClient added in v1.229.0

func NewClient[Req any, Res any](client *http.Client, mar *marshaller.Map) *Client[Req, Res]

NewClient for HTTP.

func (*Client[Req, Res]) Call added in v1.229.0

func (c *Client[Req, Res]) Call(ctx context.Context, url, contentType string, req *Req) (*Res, error)

Call for HTTP.

type Config added in v1.165.0

type Config struct {
	TLS  *tls.Config
	Port string
}

Config for HTTP.

type Context added in v1.225.0

type Context interface {
	// Request of the context.
	Request() *http.Request

	// Response of the context.
	Response() http.ResponseWriter

	context.Context
}

Context for HTTP.

type Handler added in v1.218.0

type Handler[Req any, Res any] interface {
	// Handle func for request/response.
	Handle(ctx Context, req *Req) (*Res, error)
}

Handler for HTTP.

type Server added in v1.164.0

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

Server for HTTP.

func NewServer added in v1.164.0

func NewServer(server *http.Server, cfg *Config) (*Server, error)

NewServer for HTTP.

func (*Server) IsEnabled added in v1.166.2

func (s *Server) IsEnabled() bool

IsEnabled for server.

func (*Server) Serve added in v1.164.0

func (s *Server) Serve() error

Serve the underlying server.

func (*Server) Shutdown added in v1.164.0

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

Shutdown the underlying server.

func (*Server) String added in v1.165.0

func (s *Server) String() string

Jump to

Keyboard shortcuts

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