Http router

This commit is contained in:
Meutel 2017-07-12 19:10:02 +02:00
parent e02f6b5cee
commit 1ccc6007ed
2 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@ -52,3 +52,4 @@ echorot13/echorot13
chatserver/chatserver chatserver/chatserver
example-httptcp/example-httptcp example-httptcp/example-httptcp
example-httpserver/example-httpserver example-httpserver/example-httpserver
http-router/http-router

26
http-router/main.go Normal file
View File

@ -0,0 +1,26 @@
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)
}