[server] If quiet is set, do not log error while handling requests.
This commit is contained in:
parent
c2ef18990f
commit
e2f11ea2a8
2 changed files with 32 additions and 10 deletions
|
@ -94,12 +94,16 @@ func (_server *server) Serve (_context *fasthttp.RequestCtx) () {
|
||||||
_pathLen := len (_path)
|
_pathLen := len (_path)
|
||||||
|
|
||||||
if ! bytes.Equal (StringToBytes (http.MethodGet), _method) {
|
if ! bytes.Equal (StringToBytes (http.MethodGet), _method) {
|
||||||
log.Printf ("[ww] [bce7a75b] invalid method `%s` for `%s`!\n", BytesToString (_requestHeaders.Method ()), *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ww] [bce7a75b] invalid method `%s` for `%s`!\n", BytesToString (_requestHeaders.Method ()), *_requestUriString)
|
||||||
|
}
|
||||||
_server.ServeError (_context, http.StatusMethodNotAllowed, nil, true)
|
_server.ServeError (_context, http.StatusMethodNotAllowed, nil, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (_pathLen == 0) || (_path[0] != '/') {
|
if (_pathLen == 0) || (_path[0] != '/') {
|
||||||
log.Printf ("[ww] [fa6b1923] invalid path `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ww] [fa6b1923] invalid path `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
_server.ServeError (_context, http.StatusBadRequest, nil, true)
|
_server.ServeError (_context, http.StatusBadRequest, nil, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -226,14 +230,18 @@ func (_server *server) Serve (_context *fasthttp.RequestCtx) () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if _fingerprints == nil {
|
if _fingerprints == nil {
|
||||||
log.Printf ("[ww] [7416f61d] not found `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ww] [7416f61d] not found `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
_server.ServeError (_context, http.StatusNotFound, nil, true)
|
_server.ServeError (_context, http.StatusNotFound, nil, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_fingerprintsSplit := bytes.IndexByte (_fingerprints, ':')
|
_fingerprintsSplit := bytes.IndexByte (_fingerprints, ':')
|
||||||
if _fingerprintsSplit < 0 {
|
if _fingerprintsSplit < 0 {
|
||||||
log.Printf ("[ee] [7ee6c981] invalid data fingerprints for `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ee] [7ee6c981] invalid data fingerprints for `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
_server.ServeError (_context, http.StatusInternalServerError, nil, false)
|
_server.ServeError (_context, http.StatusInternalServerError, nil, false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -256,7 +264,9 @@ func (_server *server) Serve (_context *fasthttp.RequestCtx) () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _data == nil {
|
if _data == nil {
|
||||||
log.Printf ("[ee] [0165c193] missing data content for `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ee] [0165c193] missing data content for `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
_server.ServeError (_context, http.StatusInternalServerError, nil, false)
|
_server.ServeError (_context, http.StatusInternalServerError, nil, false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -277,7 +287,9 @@ func (_server *server) Serve (_context *fasthttp.RequestCtx) () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _dataMetaRaw == nil {
|
if _dataMetaRaw == nil {
|
||||||
log.Printf ("[ee] [e8702411] missing data metadata for `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ee] [e8702411] missing data metadata for `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
_server.ServeError (_context, http.StatusInternalServerError, nil, false)
|
_server.ServeError (_context, http.StatusInternalServerError, nil, false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -296,15 +308,21 @@ func (_server *server) Serve (_context *fasthttp.RequestCtx) () {
|
||||||
if (_value >= 200) && (_value <= 599) {
|
if (_value >= 200) && (_value <= 599) {
|
||||||
_responseStatus = _value
|
_responseStatus = _value
|
||||||
} else {
|
} else {
|
||||||
log.Printf ("[c2f7ec36] invalid data metadata for `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ee] [c2f7ec36] invalid data metadata for `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
_responseStatus = http.StatusInternalServerError
|
_responseStatus = http.StatusInternalServerError
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf ("[beedae55] invalid data metadata for `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ee] [beedae55] invalid data metadata for `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
_responseStatus = http.StatusInternalServerError
|
_responseStatus = http.StatusInternalServerError
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
log.Printf ("[7acc7d90] invalid data metadata for `%s`!\n", *_requestUriString)
|
if !_server.quiet {
|
||||||
|
log.Printf ("[ee] [7acc7d90] invalid data metadata for `%s`!\n", *_requestUriString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +415,9 @@ func (_server *server) ServeError (_context *fasthttp.RequestCtx, _status uint,
|
||||||
|
|
||||||
_response.SetStatusCode (int (_status))
|
_response.SetStatusCode (int (_status))
|
||||||
|
|
||||||
LogError (_error, "")
|
if (_error != nil) && !_server.quiet {
|
||||||
|
LogError (_error, "[23d6cb35] failed handling request!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,9 @@
|
||||||
|
|
||||||
--limit-memory <MiB>
|
--limit-memory <MiB>
|
||||||
|
|
||||||
|
--quiet
|
||||||
--debug
|
--debug
|
||||||
|
|
||||||
--dummy
|
--dummy
|
||||||
--delay <duration>
|
--delay <duration>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue