Commit 973b9cad by Torkel Ödegaard

moved all http route handling into single package named api

parent 1663cbbb
package routes
package api
import (
"github.com/Unknwon/macaron"
"github.com/torkelo/grafana-pro/pkg/api/dtos"
"github.com/torkelo/grafana-pro/pkg/middleware"
"github.com/torkelo/grafana-pro/pkg/routes/api"
"github.com/torkelo/grafana-pro/pkg/routes/dtos"
"github.com/torkelo/grafana-pro/pkg/routes/login"
)
func Register(m *macaron.Macaron) {
......@@ -13,32 +11,32 @@ func Register(m *macaron.Macaron) {
// index
m.Get("/", auth, Index)
m.Post("/logout", login.LogoutPost)
m.Post("/login", login.LoginPost)
m.Post("/logout", LogoutPost)
m.Post("/login", LoginPost)
// login
m.Get("/login", Index)
m.Get("/login/:name", login.OAuthLogin)
m.Get("/login/:name", OAuthLogin)
// account
m.Get("/account/", auth, Index)
m.Get("/api/account/", auth, api.GetAccount)
m.Post("/api/account/collaborators/add", auth, api.AddCollaborator)
m.Get("/api/account/others", auth, api.GetOtherAccounts)
m.Get("/api/account/", auth, GetAccount)
m.Post("/api/account/collaborators/add", auth, AddCollaborator)
m.Get("/api/account/others", auth, GetOtherAccounts)
// user register
m.Get("/register/*_", Index)
m.Post("/api/account", api.CreateAccount)
m.Post("/api/account", CreateAccount)
// dashboards
m.Get("/dashboard/*", auth, Index)
m.Get("/api/dashboards/:slug", auth, api.GetDashboard)
m.Get("/api/search/", auth, api.Search)
m.Post("/api/dashboard/", auth, api.PostDashboard)
m.Delete("/api/dashboard/:slug", auth, api.DeleteDashboard)
m.Get("/api/dashboards/:slug", auth, GetDashboard)
m.Get("/api/search/", auth, Search)
m.Post("/api/dashboard/", auth, PostDashboard)
m.Delete("/api/dashboard/:slug", auth, DeleteDashboard)
// rendering
m.Get("/render/*", auth, api.RenderToPng)
m.Get("/render/*", auth, RenderToPng)
}
func Index(ctx *middleware.Context) {
......
package api
import (
"github.com/torkelo/grafana-pro/pkg/api/dtos"
"github.com/torkelo/grafana-pro/pkg/middleware"
"github.com/torkelo/grafana-pro/pkg/models"
"github.com/torkelo/grafana-pro/pkg/routes/dtos"
"github.com/torkelo/grafana-pro/pkg/utils"
)
......
package api
import (
"github.com/torkelo/grafana-pro/pkg/api/dtos"
"github.com/torkelo/grafana-pro/pkg/middleware"
"github.com/torkelo/grafana-pro/pkg/models"
"github.com/torkelo/grafana-pro/pkg/routes/dtos"
"github.com/torkelo/grafana-pro/pkg/utils"
)
......
package login
package api
import (
"github.com/torkelo/grafana-pro/pkg/api/dtos"
"github.com/torkelo/grafana-pro/pkg/log"
"github.com/torkelo/grafana-pro/pkg/middleware"
"github.com/torkelo/grafana-pro/pkg/models"
"github.com/torkelo/grafana-pro/pkg/routes/dtos"
"github.com/torkelo/grafana-pro/pkg/utils"
)
......
......@@ -12,9 +12,9 @@ import (
"github.com/codegangsta/cli"
"github.com/macaron-contrib/session"
"github.com/torkelo/grafana-pro/pkg/api"
"github.com/torkelo/grafana-pro/pkg/log"
"github.com/torkelo/grafana-pro/pkg/middleware"
"github.com/torkelo/grafana-pro/pkg/routes"
"github.com/torkelo/grafana-pro/pkg/setting"
"github.com/torkelo/grafana-pro/pkg/social"
"github.com/torkelo/grafana-pro/pkg/stores/sqlstore"
......@@ -78,7 +78,7 @@ func runWeb(*cli.Context) {
}
m := newMacaron()
routes.Register(m)
api.Register(m)
var err error
listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment