mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-18 07:24:31 +01:00
- These changes makes the API incombatible with previous versions - Added new types for error handling, success responses, and health checks. - Updated health check logic to utilize the new types for better clarity and structure. - Refactored existing handlers to improve response consistency and error handling. - Updated Makefile to include a new target for generating API types from Swagger. - Updated "new agent" API to respond an encrypted cert pair
29 lines
740 B
Go
29 lines
740 B
Go
package v1
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
apitypes "github.com/yusing/go-proxy/internal/api/types"
|
|
config "github.com/yusing/go-proxy/internal/config/types"
|
|
)
|
|
|
|
// @x-id "reload"
|
|
// @BasePath /api/v1
|
|
// @Summary Reload config
|
|
// @Description Reload config
|
|
// @Tags v1
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} apitypes.SuccessResponse
|
|
// @Failure 403 {object} apitypes.ErrorResponse
|
|
// @Failure 500 {object} apitypes.ErrorResponse
|
|
// @Router /reload [post]
|
|
func Reload(c *gin.Context) {
|
|
if err := config.GetInstance().Reload(); err != nil {
|
|
c.Error(apitypes.InternalServerError(err, "failed to reload config"))
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, apitypes.Success("config reloaded"))
|
|
}
|