ozzo-routing icon indicating copy to clipboard operation
ozzo-routing copied to clipboard

`http: multiple response.WriteHeader calls` when using fault.Recovery

Open darasion opened this issue 7 years ago • 0 comments

test code is:

package main

import (
    "github.com/go-ozzo/ozzo-routing"
    "github.com/go-ozzo/ozzo-routing/fault"
    "log"
    "net/http"
)

func main() {
    router := routing.New()
    router.Use(
        fault.Recovery(log.Printf, func(c *routing.Context, err error) error {
            c.Write(err)
            return nil 
        }), 
    )   
    http.Handle("/", router)
    http.ListenAndServe(":8123", nil)
}

on error occurred, it will log an additional message: http: multiple response.WriteHeader calls

2018/01/24 12:08:54 Not Found
2018/01/24 12:08:54 http: multiple response.WriteHeader calls

darasion avatar Jan 24 '18 05:01 darasion