httputils

package
v0.0.0-...-a423d60 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ContentTypeApplicationJSON missing godoc
	ContentTypeApplicationJSON = "application/json"
	// HeaderContentTypeKey missing godoc
	HeaderContentTypeKey = "Content-Type"
)

Variables

This section is empty.

Functions

func Close

func Close(ctx context.Context, closer io.Closer)

Close missing godoc

func Respond

func Respond(w http.ResponseWriter, status int)

Respond writes a http response only with status, without body

func RespondWithBody

func RespondWithBody(ctx context.Context, w http.ResponseWriter, status int, data interface{})

RespondWithBody writes a http response using with the JSON encoded data as payload

func RespondWithError

func RespondWithError(ctx context.Context, w http.ResponseWriter, status int, err error)

RespondWithError writes a http response using with the JSON encoded error wrapped in an Error struct

Types

type Error

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

Error missing godoc

type ErrorResponse

type ErrorResponse struct {
	Errors []Error `json:"errors"`
}

ErrorResponse missing godoc

Jump to

Keyboard shortcuts

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