go-examples/http-router/main.go
2017-07-12 19:10:02 +02:00

27 lines
423 B
Go

package main
import (
"io"
"net/http"
)
func main() {
http.HandleFunc("/dog/", func(res http.ResponseWriter, req *http.Request) {
io.WriteString(res, `<!DOCTYPE html>
<html>
<body>
DOG
</body>
</html>`)
})
http.HandleFunc("/cat/", func(res http.ResponseWriter, req *http.Request) {
io.WriteString(res, `<!DOCTYPE html>
<html>
<body>
CAT
</body>
</html>`)
})
http.ListenAndServe(":9000", nil)
}