Skip to content

Instantly share code, notes, and snippets.

@niratama
Created August 9, 2016 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niratama/9497ee4f04c79af3e71a581774b61cea to your computer and use it in GitHub Desktop.
Save niratama/9497ee4f04c79af3e71a581774b61cea to your computer and use it in GitHub Desktop.
package main
// $ ab -c 2 -n 100 http://localhost:8080/
import (
"fmt"
"log"
"net/http"
"github.com/lestrrat/go-apache-logformat"
)
func main() {
logger := apachelog.CombinedLog
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
lw := apachelog.NewLoggingWriter(w, r, logger)
defer lw.EmitLog()
fmt.Fprintf(lw, "OK\n")
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment