mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-06 18:03:29 +02:00
Add development errors mode
This commit is contained in:
@@ -169,6 +169,7 @@ type config struct {
|
|||||||
UserAgent string
|
UserAgent string
|
||||||
|
|
||||||
IgnoreSslVerification bool
|
IgnoreSslVerification bool
|
||||||
|
DevelopmentErrorsMode bool
|
||||||
|
|
||||||
LocalFileSystemRoot string
|
LocalFileSystemRoot string
|
||||||
S3Enabled bool
|
S3Enabled bool
|
||||||
@@ -293,6 +294,7 @@ func init() {
|
|||||||
strEnvConfig(&conf.UserAgent, "IMGPROXY_USER_AGENT")
|
strEnvConfig(&conf.UserAgent, "IMGPROXY_USER_AGENT")
|
||||||
|
|
||||||
boolEnvConfig(&conf.IgnoreSslVerification, "IMGPROXY_IGNORE_SSL_VERIFICATION")
|
boolEnvConfig(&conf.IgnoreSslVerification, "IMGPROXY_IGNORE_SSL_VERIFICATION")
|
||||||
|
boolEnvConfig(&conf.DevelopmentErrorsMode, "IMGPROXY_DEVELOPMENT_ERRORS_MODE")
|
||||||
|
|
||||||
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")
|
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.
|
* `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
|
### Compression
|
||||||
|
|
||||||
* `IMGPROXY_QUALITY`: default quality of the resulting image, percentage. Default: `80`;
|
* `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)
|
logResponse(reqID, err.StatusCode, err.Message)
|
||||||
|
|
||||||
rw.WriteHeader(err.StatusCode)
|
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) {
|
func respondWithOptions(reqID string, rw http.ResponseWriter) {
|
||||||
|
Reference in New Issue
Block a user