api

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 3 Imported by: 0

README

API

API responses in JSON format

  • Error(msg string)
  • ErrorWithData(msg string, data []interface)
  • Success(msg string)
  • SuccessWithData(msg string, data []interface)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Respond

func Respond(w http.ResponseWriter, r *http.Request, resp Response)

Respond writes a JSON or JSONP response

Types

type Response

type Response struct {
	Status  string                 `json:"status"`
	Message string                 `json:"message"`
	Data    map[string]interface{} `json:"data"`
}

Response defines an response for the API

func Error

func Error(message string) Response

Error returns an error message

func ErrorWithData

func ErrorWithData(message string, data map[string]interface{}) Response

ErrorWithData returns an error message with data

func Success

func Success(message string) Response

Success returns a success message

func SuccessWithData

func SuccessWithData(message string, data map[string]interface{}) Response

SuccessWithData returns a success message with data

Jump to

Keyboard shortcuts

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