mirror of
https://github.com/vbatts/talks.git
synced 2025-05-23 21:32:31 +00:00
2013-03: adding an old learning lunch
This commit is contained in:
parent
68f582d393
commit
24cea0199b
17 changed files with 718 additions and 0 deletions
21
2013/03-golang-learning-lunch/9-http-srv/main.go
Normal file
21
2013/03-golang-learning-lunch/9-http-srv/main.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// START OMIT
|
||||
func routeSlash(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("Got a request from %s", r.RemoteAddr)
|
||||
fmt.Fprintf(w, "It Works!\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Println("listening on 0.0.0.0:4000")
|
||||
http.HandleFunc("/", routeSlash)
|
||||
log.Fatal(http.ListenAndServe("0.0.0.0:4000", nil))
|
||||
}
|
||||
// STOP OMIT
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue