output

package
v5.2.0--beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 4 Imported by: 5

Documentation

Overview

Package output is used to send data back to client in a consistent manner.

Sending data back to client using these funcs allows the data to be easily parsable by the client since the format is always the same. The data send back is always sent back as JSON.

Responses can either be successful or error. Each has specific uses and returns data slightly differently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(title error, msg string, w http.ResponseWriter)

Error is used when an error occured within the app and we could not continue with the task This returns some data on the error so the user can diagnose it or contact an admin. This logs to appengine logs (viewable in google cloud platform) so admins can also see the error and more details (hence why http.Request is sent into the func). Responds 400 status code since this clearly was not an "ok" event.

func Success

func Success(msgType string, msgData interface{}, w http.ResponseWriter)

Success is used when no errors occured and we want to send data back to the client The msgData could be blank/empty if the user was making a request in which all the client looks for is a status ok. Sometimes no data is returned on purpose.

Types

This section is empty.

Jump to

Keyboard shortcuts

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