mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-14 19:21:46 +03:00
Move route definitions into api.go file
This commit is contained in:
parent
2bc16d6c1b
commit
7c85c867de
18
api.go
18
api.go
@ -37,6 +37,24 @@ func assetContentType(name string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func setupRoutes(router *gin.Engine) {
|
||||
router.GET("/", API_Home)
|
||||
router.POST("/connect", API_Connect)
|
||||
router.GET("/databases", API_GetDatabases)
|
||||
router.GET("/connection", API_ConnectionInfo)
|
||||
router.GET("/tables", API_GetTables)
|
||||
router.GET("/tables/:table", API_GetTable)
|
||||
router.GET("/tables/:table/info", API_GetTableInfo)
|
||||
router.GET("/tables/:table/indexes", API_TableIndexes)
|
||||
router.GET("/query", API_RunQuery)
|
||||
router.POST("/query", API_RunQuery)
|
||||
router.GET("/explain", API_ExplainQuery)
|
||||
router.POST("/explain", API_ExplainQuery)
|
||||
router.GET("/history", API_History)
|
||||
router.GET("/bookmarks", API_Bookmarks)
|
||||
router.GET("/static/:type/:name", API_ServeAsset)
|
||||
}
|
||||
|
||||
func API_Home(c *gin.Context) {
|
||||
data, err := Asset("static/index.html")
|
||||
|
||||
|
16
main.go
16
main.go
@ -152,21 +152,7 @@ func startServer() {
|
||||
router.Use(gin.BasicAuth(auth))
|
||||
}
|
||||
|
||||
router.GET("/", API_Home)
|
||||
router.POST("/connect", API_Connect)
|
||||
router.GET("/databases", API_GetDatabases)
|
||||
router.GET("/connection", API_ConnectionInfo)
|
||||
router.GET("/tables", API_GetTables)
|
||||
router.GET("/tables/:table", API_GetTable)
|
||||
router.GET("/tables/:table/info", API_GetTableInfo)
|
||||
router.GET("/tables/:table/indexes", API_TableIndexes)
|
||||
router.GET("/query", API_RunQuery)
|
||||
router.POST("/query", API_RunQuery)
|
||||
router.GET("/explain", API_ExplainQuery)
|
||||
router.POST("/explain", API_ExplainQuery)
|
||||
router.GET("/history", API_History)
|
||||
router.GET("/bookmarks", API_Bookmarks)
|
||||
router.GET("/static/:type/:name", API_ServeAsset)
|
||||
setupRoutes(router)
|
||||
|
||||
fmt.Println("Starting server...")
|
||||
go router.Run(fmt.Sprintf("%v:%v", options.HttpHost, options.HttpPort))
|
||||
|
Loading…
Reference in New Issue
Block a user