Groups
Groups
Sign in
Groups
Groups
golang-nuts
Conversations
About
Send feedback
Help
Logging with builtin http FileServer
1,279 views
Skip to first unread message
Jon Renner
unread,
Dec 18, 2013, 11:01:38 PM
12/18/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
How would I go about getting a log of traffic to the built-in http File Server?
This is what I have so far, yet it does not work (no fileserver):
http://play.golang.org/p/qwvn5vFc89
Pranav Raja
unread,
Dec 19, 2013, 2:02:38 AM
12/19/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Something like this (
http://play.golang.org/p/6E6grsIts9
) works for me locally.
Craig Mason-Jones
unread,
Dec 19, 2013, 10:07:09 PM
12/19/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Gorilla's LoggingHandler or CombinedLoggingHandler makes this very easy.
http://www.gorillatoolkit.org/pkg/handlers
An example:
package main
import (
"net/http"
"os"
"
github.com/gorilla/handlers
"
)
func main() {
http.Handle("/", handlers.CombinedLoggingHandler(os.Stdout, http.FileServer(http.Dir("."))))
http.ListenAndServe(":8123", nil)
}
All the best,
Craig
Reply all
Reply to author
Forward
0 new messages