blt/web/routes.go
2024-05-29 11:43:17 -04:00

62 lines
1.5 KiB
Go

package web
import (
"github.com/flamego/binding"
"github.com/flamego/flamego"
"git.metaunix.net/bitgoblin/blt/web/forms"
"git.metaunix.net/bitgoblin/blt/web/routes"
)
func RegisterRoutes(f *flamego.Flame) {
// index routes
f.Get("/", routes.GetDashboard)
// hardware routes
f.Group("/hardware", func() {
f.Get("", func(c flamego.Context) {
c.Redirect("/hardware/list")
})
f.Get("/list", routes.HardwareGetList)
f.Get("/create", routes.HardwareGetCreate)
f.Post("/create", binding.Form(forms.HardwareForm{}), routes.HardwarePostCreate)
f.Get("/{hardware_id}", routes.HardwareGetView)
})
// benchmark routes
f.Group("/benchmark", func() {
f.Get("", func(c flamego.Context) {
c.Redirect("/benchmark/list")
})
f.Get("/list", routes.BenchmarkGetList)
f.Get("/create", routes.BenchmarkGetCreate)
f.Post("/create", binding.Form(forms.BenchmarkForm{}), routes.BenchmarkPostCreate)
f.Get("/{benchmark_id}", routes.BenchmarkGetView)
})
// test routes
f.Group("/test", func() {
f.Get("", func(c flamego.Context) {
c.Redirect("/test/list")
})
f.Get("/list", routes.TestGetList)
f.Get("/create", routes.TestGetCreate)
f.Post("/create", binding.Form(forms.TestForm{}), routes.TestPostCreate)
f.Get("/{test_id}", routes.TestGetView)
})
// result routes
f.Group("/result", func() {
f.Post("/add", binding.Form(forms.ResultForm{}), routes.ResultPostCreate)
})
}