models

package
v0.0.0-...-dc36351 Latest Latest
Warning

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

Go to latest
Published: May 22, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIErrorErrorMarshallingHTTPResponse = &APIError{"error_marshalling_http_response", "An internal error occured while generating the response", 500}

Error served when there is an error encoding the provided data into json for a response.

View Source
var APIErrorManualMarshalledErrorMarshallingHTTPResponse = "" +
	"{" +
	"\"error\":" +
	"{" +
	"\"id\":\"" + APIErrorErrorMarshallingHTTPResponse.Id + "\"," +
	"\"message\":\"" + APIErrorErrorMarshallingHTTPResponse.Message + "\"," +
	"\"http_code\": " + string(APIErrorErrorMarshallingHTTPResponse.HTTPCode) +
	"}" +
	"}"

String representing APIErrorErrorMarshallingHTTPResponse in JSON form

This field is here for use when an error occurs marshalling an HTTPResponse object to send to a client. It was put in this file (Although used elsewhere) so that is is kept up to date with any field changes of APIError.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Id       string `json:"id"`
	Message  string `json:"message"`
	HTTPCode int    `json:"http_code"`
}

APIError provides detail about an error that occurred while handling an endpoint

IMPORTANT: Update the manual fields below (APIErrorErrorMarshallingHTTPResponse and APIErrorManualMarshalledErrorMarshallingHTTPResponse) if any changes are made to the field or their tags.

func (APIError) Error

func (e APIError) Error() string

type AppContext

type AppContext struct {
	// App config
	Config Config
	// Gorm Database
	Db *gorm.DB
}

AppContext is used to provide stateful application configuration data to stateless endpoint handlers

type AppContextProvider

type AppContextProvider interface {
	Ctx() *AppContext
}

type Config

type Config struct {
	// Google API Client Id
	GAPIClientId string
	// URI used in JWTs to identify server
	JWTServerURI string
	// Key used to sign JWSs with HS512
	JWTHMACKey string
}

Config holds application configuration values

type HTTPResponse

type HTTPResponse struct {
	Error *APIError `json:"error"`
}

func (*HTTPResponse) Serve

func (r *HTTPResponse) Serve(w http.ResponseWriter) error

Serve HTTPResponse struct as JSON with appropriate HTTP status code.

func (*HTTPResponse) WithError

func (r *HTTPResponse) WithError(id, message string, code int) *HTTPResponse

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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