response

package
v0.0.0-...-ee3c536 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONError

func JSONError(w http.ResponseWriter, r *http.Request, con Config)

JSONError handles the response for the client.

func JSONOK

func JSONOK(w http.ResponseWriter, r *http.Request, con Config)

JSONOK sends an http.StatusOK as the response together with the custom response `JSONResponse`.

Types

type Config

type Config struct {
	Message    string
	StatusCode uint
	Data       interface{}
}

Config sets the different response configuration when returning a JSON responses.

func Configure

func Configure(message string, statusCode uint, data interface{}) Config

Configure configures the response by a given message, statusCode, data.

type JSONResponse

type JSONResponse struct {
	StatusCode uint        `json:"status_code"`
	Message    string      `json:"message"`
	Success    bool        `json:"success"`
	Data       interface{} `json:"data"`
}

JSONResponse custom json response

Jump to

Keyboard shortcuts

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