1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 20:07:04 +00:00

minor improvements

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-31 09:40:27 +03:00
parent 5700690dea
commit 8d99b46801
6 changed files with 66 additions and 49 deletions

View File

@@ -3,8 +3,8 @@ package recover
import (
"fmt"
"net/http/httputil"
"runtime"
"strconv"
"github.com/kataras/iris/v12/context"
)
@@ -14,13 +14,8 @@ func init() {
}
func getRequestLogs(ctx *context.Context) string {
var status, ip, method, path string
status = strconv.Itoa(ctx.GetStatusCode())
path = ctx.Path()
method = ctx.Method()
ip = ctx.RemoteAddr()
// the date should be logged by iris' Logger, so we skip them
return fmt.Sprintf("%v %s %s %s", status, path, method, ip)
rawReq, _ := httputil.DumpRequest(ctx.Request(), false)
return string(rawReq)
}
// New returns a new recover middleware,
@@ -30,7 +25,7 @@ func New() context.Handler {
return func(ctx *context.Context) {
defer func() {
if err := recover(); err != nil {
if ctx.IsStopped() {
if ctx.IsStopped() { // handled by other middleware.
return
}