Created
August 9, 2016 08:07
-
-
Save niratama/9497ee4f04c79af3e71a581774b61cea to your computer and use it in GitHub Desktop.
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 | |
// $ 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