http

package
v4.0.0-...-ae7b6de Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

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 SszRequested

func SszRequested(req *http.Request) bool

SszRequested 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 DefaultErrorJson

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

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

func (*DefaultErrorJson) StatusCode

func (e *DefaultErrorJson) 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