httputil

package
v5.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

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

func IsRequestSsz

func IsRequestSsz(req *http.Request) bool

IsRequestSsz checks if the request object should be interpreted as ssz

func RespondWithSsz

func RespondWithSsz(req *http.Request) bool

RespondWithSsz takes a http request and checks to see if it should be requesting a ssz response.

func WriteError

func WriteError(w http.ResponseWriter, errJson HasStatusCode)

WriteError writes the error by manipulating headers and the body of the final response.

func WriteJson

func WriteJson(w http.ResponseWriter, v any)

WriteJson writes the response message in JSON format.

func WriteSsz

func WriteSsz(w http.ResponseWriter, respSsz []byte, fileName string)

WriteSsz writes the response message in ssz format

Types

type DefaultJsonError

type DefaultJsonError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

DefaultJsonError is a JSON representation of a simple error value, containing only a message and an error code.

func (*DefaultJsonError) Error

func (e *DefaultJsonError) Error() string

func (*DefaultJsonError) StatusCode

func (e *DefaultJsonError) StatusCode() int

type HasStatusCode

type HasStatusCode interface {
	StatusCode() int
}

Jump to

Keyboard shortcuts

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