Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 1.03 KB

README.md

File metadata and controls

34 lines (24 loc) · 1.03 KB

This package log and modify data for 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 FrameWork

e := echo.New()

e.Use(responselogger.EchoMiddleware(func(b []byte) []byte{
	log.Print(string(b))
	return b
}))
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))