diff options
Diffstat (limited to 'modules/caddyhttp/staticerror.go')
-rw-r--r-- | modules/caddyhttp/staticerror.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/caddyhttp/staticerror.go b/modules/caddyhttp/staticerror.go index fd1490d..0ddebfe 100644 --- a/modules/caddyhttp/staticerror.go +++ b/modules/caddyhttp/staticerror.go @@ -27,8 +27,18 @@ func init() { } // StaticError implements a simple handler that returns an error. +// This handler returns an error value, but does not write a response. +// This is useful when you want the server to act as if an error +// occurred; for example, to invoke your custom error handling logic. +// +// Since this handler does not write a response, the error information +// is for use by the server to know how to handle the error. type StaticError struct { - Error string `json:"error,omitempty"` + // The recommended HTTP status code. Can be either an integer or a + // string if placeholders are needed. Optional. Default is 500. + Error string `json:"error,omitempty"` + + // The error message. Optional. Default is no error message. StatusCode WeakString `json:"status_code,omitempty"` } |