diff --git a/.gitignore b/.gitignore index 6871f5f..7b4f01b 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ echorot13/echorot13 chatserver/chatserver example-httptcp/example-httptcp example-httpserver/example-httpserver +http-router/http-router diff --git a/http-router/main.go b/http-router/main.go new file mode 100644 index 0000000..48cc77e --- /dev/null +++ b/http-router/main.go @@ -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, ` + + + DOG + +`) + }) + http.HandleFunc("/cat/", func(res http.ResponseWriter, req *http.Request) { + io.WriteString(res, ` + + + CAT + +`) + }) + http.ListenAndServe(":9000", nil) +}