response

package
v0.0.0-...-8626fa4 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package response handles utilities for writing error and normal responses to the response writer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(res http.ResponseWriter, payload Message)

Write will write the response to the response writer payload is any json serializable object

func WriteError

func WriteError(res http.ResponseWriter, err Error, code int)

WriteError will write to the error response to the response writer

Types

type Error

type Error struct {
	//Err is the error happened in string format
	Err string `json:"error"`
}

Error is the datastructure for writing error response

type Message

type Message struct {
	//Message associated with
	Message string
	//Data is payload
	Data interface{}
}

Message is the message to be given for successfull response

Jump to

Keyboard shortcuts

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