improved log output
This commit is contained in:
parent
6531080a02
commit
996efe5421
1 changed files with 3 additions and 4 deletions
|
@ -30,7 +30,7 @@ func handleRequests(writer http.ResponseWriter, request *http.Request) {
|
||||||
requestMethod := strings.ToLower(request.Method)
|
requestMethod := strings.ToLower(request.Method)
|
||||||
user, authorized := isAuthorized(request)
|
user, authorized := isAuthorized(request)
|
||||||
if !authorized {
|
if !authorized {
|
||||||
log.Debug("denying unauthorized '" + requestMethod + "' request for path '" + requestPath + "'")
|
log.Info("denying unauthorized '"+requestMethod+"' request", "path: "+requestPath)
|
||||||
writer.WriteHeader(404)
|
writer.WriteHeader(404)
|
||||||
writer.Write([]byte("error: basic authorization failed\n"))
|
writer.Write([]byte("error: basic authorization failed\n"))
|
||||||
return
|
return
|
||||||
|
@ -38,16 +38,15 @@ func handleRequests(writer http.ResponseWriter, request *http.Request) {
|
||||||
handled := false
|
handled := false
|
||||||
switch requestMethod {
|
switch requestMethod {
|
||||||
case "get":
|
case "get":
|
||||||
log.Debug("handling '" + requestMethod + "' request for path '" + requestPath + "'...")
|
|
||||||
handled = handleGet(user, writer, request)
|
handled = handleGet(user, writer, request)
|
||||||
case "post":
|
case "post":
|
||||||
log.Debug("handling '" + requestMethod + "' request for path '" + requestPath + "'...")
|
|
||||||
handled = handlePost(user, writer, request)
|
handled = handlePost(user, writer, request)
|
||||||
}
|
}
|
||||||
if handled {
|
if handled {
|
||||||
|
log.Debug("handled '"+requestMethod+"' request", "path: "+requestPath, "user: "+user)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debug("ignoring '" + requestMethod + "' request for path '" + requestPath + "'\n")
|
log.Debug("ignoring '"+requestMethod+"' request", "path: "+requestPath, "user: "+user)
|
||||||
writer.WriteHeader(501)
|
writer.WriteHeader(501)
|
||||||
writer.Write([]byte("error: endpoint '" + requestPath + "' not implemented\n"))
|
writer.Write([]byte("error: endpoint '" + requestPath + "' not implemented\n"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue