API versioning ( basePath == /api/v2/* )

This commit is contained in:
2023-01-27 10:04:06 +01:00
parent 27b189d33a
commit d1cefb0150
10 changed files with 253 additions and 247 deletions

View File

@@ -59,7 +59,7 @@ func (r *Router) Init(e *gin.Engine) error {
return errors.New("failed to add validators - wrong engine")
}
// ================ General ================
// ================ General (unversioned) ================
commonAPI := e.Group("/api")
{
@@ -118,9 +118,9 @@ func (r *Router) Init(e *gin.Engine) error {
compat.GET("/upgrade.php", r.Wrap(r.compatHandler.Upgrade))
}
// ================ Manage API ================
// ================ Manage API (v2) ================
apiv2 := e.Group("/api/")
apiv2 := e.Group("/api/v2/")
{
apiv2.POST("/users", r.Wrap(r.apiHandler.CreateUser))
@@ -150,7 +150,7 @@ func (r *Router) Init(e *gin.Engine) error {
apiv2.DELETE("/messages/:mid", r.Wrap(r.apiHandler.DeleteMessage))
}
// ================ Send API ================
// ================ Send API (unversioned) ================
sendAPI := e.Group("")
{
@@ -159,6 +159,8 @@ func (r *Router) Init(e *gin.Engine) error {
sendAPI.POST("/send.php", r.Wrap(r.messageHandler.SendMessageCompat))
}
// ================
if r.app.Config.ReturnRawErrors {
e.NoRoute(r.Wrap(r.commonHandler.NoRoute))
}