fix(httpapi): phase 1 compliance — ERR-01, SEC-04, CDN client, scheduler docs

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-05-20 00:21:16 +07:00
co-authored by Cursor
parent aff27e8f7b
commit 1dd713514c
8 changed files with 67 additions and 19 deletions
+5 -5
View File
@@ -178,7 +178,7 @@ func writeStoreErr(w http.ResponseWriter, err error) {
writeProblem(w, http.StatusUnprocessableEntity, "Unprocessable Entity", err.Error())
return
}
writeProblem(w, http.StatusInternalServerError, "Internal Error", err.Error())
writeInternalError(w, "store", err)
}
func (s *Server) handleListCDNSources(w http.ResponseWriter, r *http.Request) {
@@ -251,20 +251,20 @@ func (s *Server) handlePreviewCDNSource(w http.ResponseWriter, r *http.Request)
writeProblem(w, http.StatusUnprocessableEntity, "Unprocessable Entity", "invalid url")
return
}
resp, err := http.DefaultClient.Do(req)
resp, err := s.cdnHTTP.Do(req)
if err != nil {
writeProblem(w, http.StatusBadGateway, "Bad Gateway", err.Error())
writeBadGateway(w, "cdn preview fetch", err)
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
_, _ = io.Copy(io.Discard, resp.Body)
writeProblem(w, http.StatusBadGateway, "Bad Gateway", fmt.Sprintf("upstream status: %s", resp.Status))
writeBadGateway(w, "cdn preview fetch", fmt.Errorf("upstream status: %s", resp.Status))
return
}
raw, err := io.ReadAll(io.LimitReader(resp.Body, 8<<20))
if err != nil {
writeProblem(w, http.StatusBadGateway, "Bad Gateway", err.Error())
writeBadGateway(w, "cdn preview read body", err)
return
}
pfxs, err := pipeline.ExtractCIDRs(string(raw), body.SourceKind, body.PrefixPath)