mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-03-22 20:21:28 +02:00
Add development errors mode
This commit is contained in:
parent
023dcadc34
commit
bd95447ca5
@ -169,6 +169,7 @@ type config struct {
|
||||
UserAgent string
|
||||
|
||||
IgnoreSslVerification bool
|
||||
DevelopmentErrorsMode bool
|
||||
|
||||
LocalFileSystemRoot string
|
||||
S3Enabled bool
|
||||
@ -293,6 +294,7 @@ func init() {
|
||||
strEnvConfig(&conf.UserAgent, "IMGPROXY_USER_AGENT")
|
||||
|
||||
boolEnvConfig(&conf.IgnoreSslVerification, "IMGPROXY_IGNORE_SSL_VERIFICATION")
|
||||
boolEnvConfig(&conf.DevelopmentErrorsMode, "IMGPROXY_DEVELOPMENT_ERRORS_MODE")
|
||||
|
||||
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")
|
||||
|
||||
|
@ -61,6 +61,10 @@ When you use imgproxy in a development environment, it can be useful to ignore S
|
||||
|
||||
* `IMGPROXY_IGNORE_SSL_VERIFICATION`: when true, disables SSL verification, so imgproxy can be used in a development environment with self-signed SSL certificates.
|
||||
|
||||
Also you may want imgproxy to respond with the same error message that it writes to the log:
|
||||
|
||||
* `IMGPROXY_DEVELOPMENT_ERRORS_MODE`: when true, imgproxy will respond with detailed error messages. Not recommended for production because some errors may contain stack trace.
|
||||
|
||||
### Compression
|
||||
|
||||
* `IMGPROXY_QUALITY`: default quality of the resulting image, percentage. Default: `80`;
|
||||
|
@ -175,7 +175,12 @@ func respondWithError(reqID string, rw http.ResponseWriter, err *imgproxyError)
|
||||
logResponse(reqID, err.StatusCode, err.Message)
|
||||
|
||||
rw.WriteHeader(err.StatusCode)
|
||||
rw.Write([]byte(err.PublicMessage))
|
||||
|
||||
if conf.DevelopmentErrorsMode {
|
||||
rw.Write([]byte(err.Message))
|
||||
} else {
|
||||
rw.Write([]byte(err.PublicMessage))
|
||||
}
|
||||
}
|
||||
|
||||
func respondWithOptions(reqID string, rw http.ResponseWriter) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user