use caddyfile instead of api
This commit is contained in:
parent
53a5e2e45a
commit
3c79a8c778
9 changed files with 206 additions and 248 deletions
|
|
@ -3,6 +3,7 @@ package app
|
|||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"os"
|
||||
osuser "os/user"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -275,10 +276,25 @@ func (a *App) handleCaddyConfig(w http.ResponseWriter, r *http.Request, _ User)
|
|||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
if a.cfg.CaddyRouteEnabled && strings.TrimSpace(a.cfg.CaddyFragmentPath) != "" {
|
||||
content, err := os.ReadFile(a.cfg.CaddyFragmentPath)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadGateway)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"format": "caddyfile",
|
||||
"content": string(content),
|
||||
})
|
||||
return
|
||||
}
|
||||
cfg, err := a.fetchCaddyConfig(r.Context())
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadGateway)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, cfg)
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"format": "json",
|
||||
"content": mustJSONPretty(cfg),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue