Add endpoints to return nginx config from disk

This commit is contained in:
Jamie Curnow
2023-01-09 15:42:56 +10:00
parent ca4d92d793
commit 5586d16afd
5 changed files with 128 additions and 0 deletions

View File

@ -81,6 +81,13 @@ func ResultErrorJSON(w http.ResponseWriter, r *http.Request, status int, message
ResultResponseJSON(w, r, status, errorResponse)
}
// ResultResponseText will write the result as text to the http output
func ResultResponseText(w http.ResponseWriter, r *http.Request, status int, content string) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(status)
fmt.Fprint(w, content)
}
// getPrettyPrintFromContext returns the PrettyPrint setting
func getPrettyPrintFromContext(r *http.Request) bool {
pretty, ok := r.Context().Value(c.PrettyPrintCtxKey).(bool)