func main() { // Initialization if core.Production { rand.Seed(time.Now().UTC().UnixNano()) } flag.Parse() // Handlers if !core.Production { log.Use() } secure.Use(nil) cors.Use(nil) compress.Use() route.Get("^/resources/(?P<id>[0-9]+)$", func(c *core.Context, params map[string]string) { id, _ := strconv.Atoi(params["id"]) response.JSON(c, map[string]interface{}{ "id": id, "type": "Resource", }) }) core.Run() }
func main() { // Initialization if core.Production { rand.Seed(time.Now().UTC().UnixNano()) } flag.Parse() i18n.Init(locales, language.English) response.TemplatesFuncs(i18n.TemplatesFuncs) // Handlers if !core.Production { log.Use() } secure.Use(nil) compress.Use() static.Use(static.DefaultMaxAge) i18n.Use(i18n.MatcherFormValue, i18n.MatcherAcceptLanguageHeader) route.Get("^/$", func(c *core.Context) { response.Template(c, "hello", nil) }) core.Run() }
func main() { // Log core.Use(func(c *core.Context) { start := time.Now() c.Next() log.Printf(" %s %s %s", c.Request.Method, c.Request.URL, time.Since(start)) }) // Response core.Use(func(c *core.Context) { fmt.Fprint(c.ResponseWriter, "Hello, World!") }) core.Run() }