Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s4l1h/responselogger
# This package log and modify data for http.ResponseWriter
https://github.com/s4l1h/responselogger
echo-framework golang golang-library golang-package httphandler
Last synced: 12 days ago
JSON representation
# This package log and modify data for http.ResponseWriter
- Host: GitHub
- URL: https://github.com/s4l1h/responselogger
- Owner: s4l1h
- Created: 2017-06-05T03:28:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-13T00:04:52.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T23:32:16.731Z (2 months ago)
- Topics: echo-framework, golang, golang-library, golang-package, httphandler
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# This package log and modify data for [http.ResponseWriter](https://golang.org/pkg/net/http/#ResponseWriter)
Bu paketi http.ResponseWriter'a yazılan dataları debug edebilmek ve değiştirmek için kullanabilirsiniz.
## Install
go get github.com/s4l1h/responselogger## Usage [Echo](https://echo.labstack.com/) FrameWork
e := echo.New()
e.Use(responselogger.EchoMiddleware(func(b []byte) []byte{
log.Print(string(b))
return b
}))## Usage [http.Handler](https://golang.org/pkg/net/http/#Handler)
http.HandleFunc("/path", responselogger.Middleware(handler,func(b []byte) []byte{
log.Print(string(b))
return b
}))## Complex Example Log and modify data
func changeAllAdultWords(b []byte) []byte {
data := string(b)
log.Print(data) // print log
data = strings.Replace(data, "porn", "***", -1) // modify data (replace "porn" to "***")
return []byte(data) // return new data for writer
}
e := echo.New()
e.Use(responselogger.EchoMiddleware(changeAllAdultWords))