xhttp

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ShutdownTimeout = time.Minute

ShutdownTimeout is the timeout for waiting all requests to complete.

Variables

This section is empty.

Functions

func ResponseJSON

func ResponseJSON(w http.ResponseWriter, status int, data interface{}) error

ResponseJSON writes a JSON response to w by using status as http status and data as payload.

func Serve

func Serve(ctx context.Context, s *http.Server) error

Serve starts s server and shutdowns it once the ctx is cancelled.

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse holds the error message.

type ErrorResponseBody

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

ErrorResponseBody is the skeleton for error messages that should be sent to client.

func NewErrorResponse

func NewErrorResponse(err error) ErrorResponseBody

NewErrorResponse creates a new http error response from err.

Jump to

Keyboard shortcuts

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