Created
January 25, 2018 06:28
-
-
Save shin1x1/fc5bab595d3586e784e7310e70af3868 to your computer and use it in GitHub Desktop.
Echo で HTTP リクエストヘッダをミドルウェアでダンプする ref: https://qiita.com/shin1x1/items/cfe7568cecbaffe0b23c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/labstack/echo" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { | |
e := echo.New() | |
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { | |
return func(c echo.Context) error { | |
if err := next(c); err != nil { | |
c.Error(err) | |
} | |
output := fmt.Sprintf("%#v", c.Request().Header) | |
os.Stdout.Write([]byte(output + "\n")) | |
return next(c) | |
} | |
}) | |
log.Fatal(e.Start(":9001")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http.Header{"Cache-Control":[]string{"max-age=0"}, "User-Agent":[]string{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"}, "Accept":[]string{"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}, "Accept-Encoding":[]string{"gzip, deflate, br"}, "Accept-Language":[]string{"ja,en-US;q=0.9,en;q=0.8"}, "Connection":[]string{"keep-alive"}, "Upgrade-Insecure-Requests":[]string{"1"}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment