routes

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2015 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQuote

func GetQuote(r *http.Request, enc Encoder, parms martini.Params) (int, string)

func GetTest

func GetTest(r *http.Request, parms martini.Params) (int, string)

func Must

func Must(data string, err error) string

Because `panic`s are caught by martini's Recovery handler, it can be used to return server-side errors (500). Some helpful text message should probably be sent, although not the technical error (which is printed in the log).

func SetQuoteSources

func SetQuoteSources(sources map[string]models.QuoteSource)

Types

type Encoder

type Encoder interface {
	EncodeOne(v interface{}) (string, error)
	Encode(v ...interface{}) (string, error)
}

An Encoder implements an encoding format of values to be sent as response to requests on the API endpoints.

type JsonEncoder

type JsonEncoder struct{}

func (JsonEncoder) Encode

func (_ JsonEncoder) Encode(v ...interface{}) (string, error)

func (JsonEncoder) EncodeOne

func (_ JsonEncoder) EncodeOne(v interface{}) (string, error)

JsonEncoder is an Encoder that produces JSON-formatted responses.

type TextEncoder

type TextEncoder struct{}

func (TextEncoder) Encode

func (_ TextEncoder) Encode(v ...interface{}) (string, error)

func (TextEncoder) EncodeOne

func (e TextEncoder) EncodeOne(v ...interface{}) (string, error)

TextEncoder is an Encoder that produces plain text-formatted responses.

type XmlEncoder

type XmlEncoder struct{}

func (XmlEncoder) Encode

func (_ XmlEncoder) Encode(v ...interface{}) (string, error)

func (XmlEncoder) EncodeOne

func (e XmlEncoder) EncodeOne(v interface{}) (string, error)

XmlEncoder is an Encoder that produces XML-formatted responses.

Jump to

Keyboard shortcuts

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