package httpapi

import (
	"net/http"
	"strings"
)

// getNetworkProxyConfig godoc
// @Summary 获取网络代理配置
// @Description 管理端查看服务当前使用的全局 HTTP 代理配置及来源。
// @Tags config
// @Produce json
// @Security BearerAuth
// @Success 200 {object} NetworkProxyConfigResponse
// @Failure 401 {object} ErrorEnvelope
// @Failure 403 {object} ErrorEnvelope
// @Router /api/admin/config/network-proxy [get]
func (s *Server) getNetworkProxyConfig(w http.ResponseWriter, r *http.Request) {
	globalHTTPProxy := strings.TrimSpace(s.cfg.GlobalHTTPProxy)
	writeJSON(w, http.StatusOK, map[string]any{
		"globalHttpProxy":       globalHTTPProxy,
		"globalHttpProxySet":    globalHTTPProxy != "",
		"globalHttpProxySource": strings.TrimSpace(s.cfg.GlobalHTTPProxySource),
	})
}
