app

package module
v0.0.0-...-41d348d Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2016 License: MIT Imports: 6 Imported by: 0

README

Google App Engine Template

This is my template for Google App Engine (GAE) Golang projects.

Feel free to steal this and use it for your own servers. The need for this arose when a lot of my GAE projects needed the same structure. A RESTful API, with a CRON and some static files.

This seems to work well for me. Hope it's useful!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CRONJOBS = CronJobs{
	CronJob{
		"/tasks/test",
		TestCronjob,
	},
}
View Source
var FILE_ROUTES = FileRoutes{
	FileRoute{
		"/",
		"./static/index.html",
	},
}
View Source
var JSON_ROUTES = JSONRoutes{
	JSONRoute{
		"/api/test_results",
		GET,
		TestHander,
	},
}

Functions

func HandleCron

func HandleCron(handler httprouter.Handle) httprouter.Handle

func HandleFile

func HandleFile(file string) httprouter.Handle

func HandleJson

func HandleJson(handler RestEndpoint) httprouter.Handle

func TestCronjob

func TestCronjob(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func TestHander

func TestHander(w http.ResponseWriter, r *http.Request, _ httprouter.Params) interface{}

Types

type CronJob

type CronJob struct {
	Path string
	Job  httprouter.Handle
}

type CronJobs

type CronJobs []CronJob

type Error

type Error struct {
	Code    int         `json:"code"`
	Message interface{} `json:"message"`
}

type FileRoute

type FileRoute struct {
	Path string
	File string
}

type FileRoutes

type FileRoutes []FileRoute

type HTTPMethod

type HTTPMethod int
const (
	GET HTTPMethod = 1 << iota
	POST
	PUT
	DELETE
)

type JSONRoute

type JSONRoute struct {
	Path    string
	Method  HTTPMethod
	Handler RestEndpoint
}

type JSONRoutes

type JSONRoutes []JSONRoute

type RestEndpoint

type RestEndpoint func(http.ResponseWriter, *http.Request, httprouter.Params) interface{}

type Test

type Test struct {
	Timestamp int64  `json:"timestamp"`
	Message   string `json:"message"`
}

type TestResults

type TestResults []Test

Jump to

Keyboard shortcuts

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