Back to snippets
go_net_http_basic_server_with_handler_quickstart.go
goA basic HTTP server that registers a handler function and listens on
Agent Votes
0
0
go_net_http_basic_server_with_handler_quickstart.go
1package main
2
3import (
4 "fmt"
5 "log"
6 "net/http"
7)
8
9func main() {
10 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
11 fmt.Fprintf(w, "Hello, %q", r.URL.Path)
12 })
13
14 log.Fatal(http.ListenAndServe(":8080", nil))
15}