httpx

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: ISC Imports: 5 Imported by: 0

Documentation

Overview

httpx provides extensions for http applications and services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, err error, defaultStatusCode int)

Error responds to an HTTP request with an error. If the given error does not specify a status code, the default status code will be used.

Types

type ClientError

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

ClientError is a custom error type for errors happening when calling an HTTP endpoint.

func NewClientError

func NewClientError(resp *http.Response) *ClientError

NewClientError creates a new HTTP client error.

func (*ClientError) Error

func (e *ClientError) Error() string

func (*ClientError) StatusCode

func (e *ClientError) StatusCode() int

StatusCode returns the status code of the HTTP response.

type Middleware

type Middleware interface {
	Wrap(next http.HandlerFunc) http.HandlerFunc
}

Middleware is an interface for wrapping an HTTP handler function.

type ServerError

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

ServerError is a custom error type for errors happening in HTTP handlers.

func NewServerError

func NewServerError(err error, statusCode int) *ServerError

NewServerError creates a new HTTP server error.

func (*ServerError) StatusCode

func (e *ServerError) StatusCode() int

StatusCode returns the appropriate HTTP status code for the error.

Jump to

Keyboard shortcuts

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