httputil

package
v0.0.0-...-736f05d Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRealIP

func GetRealIP(r *http.Request) string

func IsPrivateIP

func IsPrivateIP(ipAddr string) (bool, error)

func RespondSuccess

func RespondSuccess(w http.ResponseWriter)

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, message string)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

Types

type HttpError

type HttpError struct {
	Code    int
	Err     error
	Message string
}

func DecodeJSONBody

func DecodeJSONBody(w http.ResponseWriter, r *http.Request, dst interface{}) *HttpError

func NewBadRequestError

func NewBadRequestError(err error, msg string) *HttpError

func NewForbiddenError

func NewForbiddenError() *HttpError

func NewHttpError

func NewHttpError(code int, err error, msg string) *HttpError

func NewInternalError

func NewInternalError(err error) *HttpError

func NewNotFoundError

func NewNotFoundError() *HttpError

func NewRequestEntityTooLargeError

func NewRequestEntityTooLargeError(err error, msg string) *HttpError

func NewUnauthorizedError

func NewUnauthorizedError(err error) *HttpError

func (*HttpError) Abort

func (e *HttpError) Abort(w http.ResponseWriter, r *http.Request)

func (*HttpError) Error

func (e *HttpError) Error() string

Jump to

Keyboard shortcuts

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