2024-02-10 15:17:34 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/pikami/cosmium/api/handlers"
|
2024-02-12 19:38:03 +00:00
|
|
|
"github.com/pikami/cosmium/api/handlers/middleware"
|
2024-02-10 15:17:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func CreateRouter() *gin.Engine {
|
|
|
|
router := gin.Default()
|
|
|
|
|
2024-02-12 19:38:03 +00:00
|
|
|
router.Use(middleware.RequestLogger())
|
|
|
|
|
2024-02-10 23:44:20 +00:00
|
|
|
router.GET("/dbs/:databaseId/colls/:collId/pkranges", handlers.GetPartitionKeyRanges)
|
|
|
|
|
|
|
|
router.POST("/dbs/:databaseId/colls/:collId/docs", handlers.DocumentsPost)
|
|
|
|
router.GET("/dbs/:databaseId/colls/:collId/docs", handlers.GetAllDocuments)
|
|
|
|
router.GET("/dbs/:databaseId/colls/:collId/docs/:docId", handlers.GetDocument)
|
2024-02-14 18:36:57 +00:00
|
|
|
router.PUT("/dbs/:databaseId/colls/:collId/docs/:docId", handlers.ReplaceDocument)
|
2024-02-10 23:44:20 +00:00
|
|
|
router.DELETE("/dbs/:databaseId/colls/:collId/docs/:docId", handlers.DeleteDocument)
|
|
|
|
|
2024-02-10 16:52:41 +00:00
|
|
|
router.POST("/dbs/:databaseId/colls", handlers.CreateCollection)
|
|
|
|
router.GET("/dbs/:databaseId/colls", handlers.GetAllCollections)
|
|
|
|
router.GET("/dbs/:databaseId/colls/:collId", handlers.GetCollection)
|
|
|
|
router.DELETE("/dbs/:databaseId/colls/:collId", handlers.DeleteCollection)
|
|
|
|
|
2024-02-10 15:17:34 +00:00
|
|
|
router.POST("/dbs", handlers.CreateDatabase)
|
2024-02-10 16:52:41 +00:00
|
|
|
router.GET("/dbs", handlers.GetAllDatabases)
|
|
|
|
router.GET("/dbs/:databaseId", handlers.GetDatabase)
|
|
|
|
router.DELETE("/dbs/:databaseId", handlers.DeleteDatabase)
|
|
|
|
|
2024-02-10 19:05:08 +00:00
|
|
|
router.GET("/dbs/:databaseId/colls/:collId/udfs", handlers.GetAllUserDefinedFunctions)
|
|
|
|
router.GET("/dbs/:databaseId/colls/:collId/sprocs", handlers.GetAllStoredProcedures)
|
|
|
|
router.GET("/dbs/:databaseId/colls/:collId/triggers", handlers.GetAllTriggers)
|
|
|
|
|
|
|
|
router.GET("/offers", handlers.GetOffers)
|
2024-02-10 15:17:34 +00:00
|
|
|
router.GET("/", handlers.GetServerInfo)
|
|
|
|
|
2024-02-13 23:47:51 +00:00
|
|
|
handlers.RegisterExplorerHandlers(router)
|
|
|
|
|
2024-02-10 15:17:34 +00:00
|
|
|
return router
|
|
|
|
}
|