MCPcopy Create free account
hub / github.com/caddyserver/caddy / ServeHTTP

Method ServeHTTP

modules/caddyhttp/staticerror.go:97–109  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, _ Handler)

Source from the content-addressed store, hash-verified

95}
96
97func (e StaticError) ServeHTTP(w http.ResponseWriter, r *http.Request, _ Handler) error {
98 repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
99
100 statusCode := http.StatusInternalServerError
101 if codeStr := e.StatusCode.String(); codeStr != "" {
102 intVal, err := strconv.Atoi(repl.ReplaceAll(codeStr, ""))
103 if err != nil {
104 return Error(http.StatusInternalServerError, err)
105 }
106 statusCode = intVal
107 }
108 return Error(statusCode, fmt.Errorf("%s", repl.ReplaceKnown(e.Error, "")))
109}
110
111// Interface guard
112var (

Callers

nothing calls this directly

Calls 5

ReplaceAllMethod · 0.80
ReplaceKnownMethod · 0.80
ErrorFunction · 0.70
ValueMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected