-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdoc.go
43 lines (33 loc) · 1 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Package chromemiddleware implements a Chrome Logger middleware for Traffic.
This is a Middleware for traffic (https://github.com/pilu/traffic).
It allows to send logs to the Chrome console if you have the Chrome Logger extension (http://craig.is/writing/chrome-logger) installed.
Usage:
package main
import (
"log"
"fmt"
"net/http"
"github.com/pilu/traffic"
"github.com/pilu/traffic-chromelogger"
)
func rootHandler(w traffic.ResponseWriter, r *http.Request) {
logger := w.GetVar("chromelogger").(*chromelogger.Logger)
logger.Log("Hello")
logger.Log(map[string]string{
"foo": "bar",
})
fmt.Fprint(w, "Hello, check your Chrome console after activating the Chrome Logger extension.\n")
}
func main() {
router := traffic.New()
router.AddMiddleware(chromelogger.New())
router.Get("/", rootHandler)
http.Handle("/", router)
err := http.ListenAndServe(":7000", nil)
if err != nil {
log.Fatal(err)
}
}
*/
package chromelogger