httputils

package
v0.0.0-...-0e76970 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0, BSD-2-Clause Imports: 6 Imported by: 0

README

httputils

Misc Golang HTTP Utilities

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, code int, msg string, logErr error)

func InternalServerError

func InternalServerError(w http.ResponseWriter, msg string, logErr error)

The following functions are shorthand for creating and emitting the error all at once

func RequestAcceptsJSON

func RequestAcceptsJSON(r *http.Request) error

Types

type HttpError

type HttpError struct {
	Skip int // callstack frames to skip for debug tracking

	Errs binding.Errors

	Msg  string
	Code int

	LogMsg string
}

func NewHttpError

func NewHttpError() *HttpError

HttpError represents both the error to send to the user and the error to log.

func (*HttpError) Error

func (herr *HttpError) Error(code int, msg string, logErr error)

func (*HttpError) Errors

func (herr *HttpError) Errors(errs binding.Errors)

func (*HttpError) InternalServerError

func (herr *HttpError) InternalServerError(msg string, logErr error)

func (*HttpError) OK

func (herr *HttpError) OK() bool

func (*HttpError) Write

func (herr *HttpError) Write(w http.ResponseWriter)

Jump to

Keyboard shortcuts

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