httputils

package
v0.0.0-...-74ede58 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientErrorResponse

type ClientErrorResponse struct {
	StatusCode int           `json:"statusCode"`
	Error      localErrs.Err `json:"error"`
	Timestamp  time.Time     `json:"timestamp"`
}

ClientErrorResponse standardizes responses with 400-499 status code

type Sender

type Sender struct {
	Render *render.Render
}

func (*Sender) JSON

func (s *Sender) JSON(w http.ResponseWriter, statusCode int, v interface{}) error

JSON formats the v in a json format and sends it to the client with w. If the statusCode is specific for a error, then v is assumed to be a string, an error or an custom errors.Err struct

type ServerErrorResponse

type ServerErrorResponse struct {
	StatusCode int           `json:"statusCode"`
	Error      localErrs.Err `json:"error"`
	Timestamp  time.Time     `json:"timestamp"`
}

ServerErrorResponse standardizes responses with 500-599 status code

type SuccessfulResponse

type SuccessfulResponse struct {
	Data      interface{} `json:"data"`
	Timestamp time.Time   `json:"timestamp"`
}

SuccessfulResponse standardizes responses with 200-299 status code

Jump to

Keyboard shortcuts

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