xhttp

package
v0.14.1-0...-8b31b97 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

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