app

package
v0.0.0-...-f05d2e9 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Routes = struct {
	CreateUser, GetUser,
	GetAnimals,
	ListMoods, SetMood, GetMood, DeleteMood,
	ListConversations, CreateConversation, GetConversation, DeleteConversation,
	CreateLine, GetLine, DeleteLine *pat.Pattern
}{
	CreateUser: pat.Post("/users"),
	GetUser:    pat.Get("/users/:id"),

	GetAnimals: pat.Get("/animals"),

	ListMoods:  pat.Get("/moods"),
	SetMood:    pat.Put("/moods/:mood"),
	GetMood:    pat.Get("/moods/:mood"),
	DeleteMood: pat.Delete("/moods/:mood"),

	ListConversations:  pat.Get("/conversations"),
	CreateConversation: pat.Post("/conversations"),
	GetConversation:    pat.Get("/conversations/:conversation"),
	DeleteConversation: pat.Delete("/conversations/:conversation"),

	CreateLine: pat.Post("/conversations/:conversation/lines"),
	GetLine:    pat.Get("/conversations/:conversation/lines/:line"),
	DeleteLine: pat.Delete("/conversations/:conversation/lines/:line"),
}

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App encapsulates the handlers for the saypi API

func New

func New(config *Configuration) (*App, error)

New creates an App for the given configuration.

func (*App) Close

func (a *App) Close() error

Close cleans up any resources used by the app such as database connections.

func (*App) ServeHTTP

func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Configuration

type Configuration struct {
	DBDSN     string // postgres data source name
	DBMaxIdle int    // maximum number of idle DB connections
	DBMaxOpen int    // maximum number of open DB connections

	IPPerMinute int // maximum number of requests per IP per minute
	IPRateBurst int // maximum burst of requests from an IP

	UserSecret []byte // secret for generating secure user tokens
}

Configuration represents the configuration for an App

Jump to

Keyboard shortcuts

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