mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-20 19:38:39 +00:00
40 lines
912 B
Go
40 lines
912 B
Go
package api
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
ctx "github.com/smira/aptly/context"
|
|
"net/http"
|
|
)
|
|
|
|
var context *ctx.AptlyContext
|
|
|
|
// Router returns prebuilt with routes http.Handler
|
|
func Router(c *ctx.AptlyContext) http.Handler {
|
|
context = c
|
|
|
|
router := gin.Default()
|
|
router.Use(gin.ErrorLogger())
|
|
|
|
root := router.Group("/api")
|
|
{
|
|
root.GET("/repos", apiReposList)
|
|
root.POST("/repos", apiReposCreate)
|
|
root.GET("/repos/:name", apiReposShow)
|
|
root.PUT("/repos/:name", apiReposEdit)
|
|
root.DELETE("/repos/:name", apiReposDrop)
|
|
|
|
root.GET("/repos/:name/packages", apiReposPackagesShow)
|
|
root.POST("/repos/:name/packages", apiReposPackagesAdd)
|
|
}
|
|
|
|
{
|
|
root.GET("/files", apiFilesListDirs)
|
|
root.POST("/files/:dir", apiFilesUpload)
|
|
root.GET("/files/:dir", apiFilesListFiles)
|
|
root.DELETE("/files/:dir", apiFilesDeleteDir)
|
|
root.DELETE("/files/:dir/:name", apiFilesDeleteFile)
|
|
}
|
|
|
|
return router
|
|
}
|