mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 04:20:50 +08:00
- Eliminated `allow-localhost-unauthenticated` configuration field and its usage. - Removed associated management API handlers and middleware logic. - Simplified authentication middleware by deprecating localhost-specific checks.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package management
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (h *Handler) GetConfig(c *gin.Context) {
|
|
c.JSON(200, h.cfg)
|
|
}
|
|
|
|
// Debug
|
|
func (h *Handler) GetDebug(c *gin.Context) { c.JSON(200, gin.H{"debug": h.cfg.Debug}) }
|
|
func (h *Handler) PutDebug(c *gin.Context) { h.updateBoolField(c, func(v bool) { h.cfg.Debug = v }) }
|
|
|
|
// Request log
|
|
func (h *Handler) GetRequestLog(c *gin.Context) { c.JSON(200, gin.H{"request-log": h.cfg.RequestLog}) }
|
|
func (h *Handler) PutRequestLog(c *gin.Context) {
|
|
h.updateBoolField(c, func(v bool) { h.cfg.RequestLog = v })
|
|
}
|
|
|
|
// Request retry
|
|
func (h *Handler) GetRequestRetry(c *gin.Context) {
|
|
c.JSON(200, gin.H{"request-retry": h.cfg.RequestRetry})
|
|
}
|
|
func (h *Handler) PutRequestRetry(c *gin.Context) {
|
|
h.updateIntField(c, func(v int) { h.cfg.RequestRetry = v })
|
|
}
|
|
|
|
// Proxy URL
|
|
func (h *Handler) GetProxyURL(c *gin.Context) { c.JSON(200, gin.H{"proxy-url": h.cfg.ProxyURL}) }
|
|
func (h *Handler) PutProxyURL(c *gin.Context) {
|
|
h.updateStringField(c, func(v string) { h.cfg.ProxyURL = v })
|
|
}
|
|
func (h *Handler) DeleteProxyURL(c *gin.Context) {
|
|
h.cfg.ProxyURL = ""
|
|
h.persist(c)
|
|
}
|