Go net/http
compatible middleware for Apache style logging.
Simple. Small. Dependency free.
Originally taken from imaginary
package, now isolated as standalone package for better reusability.
go get gopkg.in/h2non/apachelog.v0
package main
import (
"fmt"
"gopkg.in/h2non/apachelog.v0"
"net/http"
"os"
)
func main() {
mux := http.NewServeMux()
// Sample route
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
})
handler := apachelog.New(mux, os.Stdout)
fmt.Println("Server listening on port: 3000")
http.ListenAndServe(":3000", handler)
}
Please, see godoc reference.
MIT - Tomas Aparicio