go-examples/http-router/main.go

27 lines
423 B
Go
Raw Normal View History

2017-07-12 17:10:02 +00:00
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)
}