Http router
This commit is contained in:
parent
e02f6b5cee
commit
1ccc6007ed
1
.gitignore
vendored
1
.gitignore
vendored
@ -52,3 +52,4 @@ echorot13/echorot13
|
||||
chatserver/chatserver
|
||||
example-httptcp/example-httptcp
|
||||
example-httpserver/example-httpserver
|
||||
http-router/http-router
|
||||
|
26
http-router/main.go
Normal file
26
http-router/main.go
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user