예제 #1
0
파일: local_test.go 프로젝트: jwulf/zedlist
func testServer() *httptest.Server {
	e := echo.New()
	e.SetRenderer(tmpl.NewRenderer())
	// middlewares
	e.Use(i18n.Langs())      // languages
	e.Use(flash.Flash())     // flash messages
	e.Use(userAuth.Normal()) // adding user context data

	// HOME
	e.Get("/", base.Home)

	// AUTH
	xauth := e.Group("/auth")

	xauth.Use(csrf.Nosurf()) // csrf protection
	xauth.Use(csrf.Tokens()) // csrf tokens

	xauth.Get("/login", Login)
	xauth.Post("/login", LoginPost)
	xauth.Get("/register", Register)
	xauth.Post("/register", RegisterPost)
	xauth.Get("/logout", Logout)

	return httptest.NewServer(e)
}
예제 #2
0
파일: base_test.go 프로젝트: jwulf/zedlist
func testServer() *httptest.Server {
	e := echo.New()
	e.SetRenderer(tmpl.NewRenderer())

	// middlewares
	e.Use(i18n.Langs())      // languages
	e.Use(flash.Flash())     // flash messages
	e.Use(userAuth.Normal()) // adding user context data

	// HOME
	e.Get("/", Home)
	e.Get("/language/:lang", SetLanguage)
	b := e.Group("/jobs")
	b.Get("/", JobsHome)
	b.Get("/view/:id", JobView)
	b.Get("/regions", RegionsHome)
	b.Get("/regions/:name", RegionsJobView)
	b.Get("/regions/:name/:from/:to", RegionsJobPaginate)

	// DOCS
	e.Get("/docs", DocsHome)
	e.Get("/docs/:name", Docs)

	return httptest.NewServer(e)
}
예제 #3
0
func testServer() *httptest.Server {
	e := echo.New()
	e.SetRenderer(tmpl.NewRenderer())

	// middlewares
	e.Use(i18n.Langs())      // languages
	e.Use(flash.Flash())     // flash messages
	e.Use(userAuth.Normal()) // adding user context data

	// BASE

	// DASHBOARD
	d := e.Group("/dash")
	d.Get("/", Home)
	d.Get("/jobs/new", JobsNewGet)
	d.Post("/jobs/new", JobsNewPost)
	d.Get("/profile", Profile)
	d.Post("/profile/name", ProfileName)

	// AUTH
	e.Post("/login", auth.LoginPost)
	return httptest.NewServer(e)
}
예제 #4
0
파일: zedlist.go 프로젝트: jwulf/zedlist
// Routes is the echo instance with all zedlist routes.
func Routes() *echo.Echo {
	e := echo.New()

	e.SetRenderer(tmpl.NewRenderer()) // Set renderer

	// middlewares
	e.Use(i18n.Langs())      // languages
	e.Use(flash.Flash())     // flash messages
	e.Use(userAuth.Normal()) // adding user context data
	e.Use(middleware.Gzip()) // Gzip

	// API
	a := e.Group("/api")
	a.Post("/jobs", japi.CreateJob)
	a.Get("/jobs/:id", japi.GetJob)
	a.Get("/jobs", japi.GetIndex)
	a.Put("/jobs", japi.UpdateJob)

	// HOME
	e.Get("/", base.Home)
	e.Get("/language/:lang", base.SetLanguage)

	// DOCS
	e.Get("/docs", base.DocsHome)
	e.Get("/docs/:name", base.Docs)

	// BASE
	b := e.Group("/jobs")
	b.Get("/", base.JobsHome)
	b.Get("/view/:id", base.JobView)
	b.Get("/regions", base.RegionsHome)
	b.Get("/regions/:name", base.RegionsJobView)
	b.Get("/regions/:name/:from/:to", base.RegionsJobPaginate)

	// AUTH
	xauth := e.Group("/auth")

	// add csrf protection
	xauth.Use(csrf.Nosurf())
	xauth.Use(csrf.Tokens())

	xauth.Get("/login", auth.Login)
	xauth.Post("/login", auth.LoginPost)
	xauth.Get("/register", auth.Register)
	xauth.Post("/register", auth.RegisterPost)
	xauth.Get("/logout", auth.Logout)

	// DASHBOARD
	dashboard := e.Group("/dash")
	dashboard.Use(userAuth.Must())
	dashboard.Get("/", dash.Home)
	dashboard.Get("/jobs/new", dash.JobsNewGet)
	dashboard.Post("/jobs/new", dash.JobsNewPost)
	dashboard.Get("/profile", dash.Profile)
	dashboard.Post("/profile/name", dash.ProfileName)

	// RESUME
	r := e.Group("/resume")
	r.Get("/", resume.Home)
	r.Post("/new", resume.Create)
	r.Get("/view:id", resume.View)
	r.Post("/update/:id", resume.Update)
	r.Post("/delete/:id", resume.Delete)

	// SEARCH
	e.Post("/search", search.Find)

	// STATIC
	box := &ass.AssetFS{
		Asset:    static.Asset,
		AssetDir: static.AssetDir,
		Prefix:   "static",
	}
	staticFileServer := http.StripPrefix("/static/", http.FileServer(box))
	e.Get("/static/*", staticFileServer)
	return e
}