Esempio n. 1
0
File: router.go Progetto: tcyd/gobed
func Routes(m *martini.Martini) {
	r := martini.NewRouter()

	r.Get(`/`, controllers.Index)
	r.Get(`/hello`, middlewares.ApiVerify(), controllers.Hello)

	// Add the router action
	m.Action(r.Handle)
}
Esempio n. 2
0
func getDependency(m *martini.Martini, i interface{}) interface{} {
	return m.Get(inject.InterfaceOf(i)).Interface()
}
Esempio n. 3
0
func configureServer(server *martini.Martini, router martini.Router) {
	server.Use(martini.Recovery())
	server.Use(middleware.Logger())
	server.Use(martini.Static("templates/public", martini.StaticOptions{SkipLogging: true}))
	server.Use(martini.Static("templates/images", martini.StaticOptions{Prefix: "images", SkipLogging: true}))
	server.Use(martini.Static("templates/styles", martini.StaticOptions{Prefix: "styles", SkipLogging: true}))
	server.Use(martini.Static("templates/scripts", martini.StaticOptions{Prefix: "scripts", SkipLogging: true}))
	server.Use(render.Renderer(render.Options{
		Layout: "layout",
	}))
	server.MapTo(router, (*martini.Routes)(nil))
	server.Action(router.Handle)
}
Esempio n. 4
0
func (m *SessionMiddleware) Setup(martini *martini.Martini) {
	martini.Use(m.ResolveSessionCookie)

	go m.cleanup()
}
Esempio n. 5
0
// UseRepositories maps the repositories within a martini context.
func UseRepositories(m *martini.Martini) {

	m.Use(func(c martini.Context, database *gorp.DbMap) {
		c.MapTo(newRepositories(database), (*Repositories)(nil))
	})
}
Esempio n. 6
0
// MapDatabase maps the database in Martini
func MapDatabase(m *martini.Martini, config *DoorbotConfig) {
	m.Map(initDatabase(config))
}