We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d45fc80 commit 4995cc5Copy full SHA for 4995cc5
main.go
@@ -3,13 +3,21 @@ package main
3
import (
4
"fmt"
5
"net/http"
6
+ "github.com/gorilla/mux"
7
)
8
-func handler(w http.ResponseWriter, r *http.Request) {
9
+func main() {
10
+ r := mux.NewRouter()
11
+ r.HandleFunc("/hello", helloHandler).Methods("GET")
12
+ r.HandleFunc("/goodbye", goodbyeHandler).Methods("GET")
13
+ http.Handle("/", r)
14
+ http.ListenAndServe(":8080", nil)
15
+}
16
+
17
+func helloHandler(w http.ResponseWriter, r *http.Request) {
18
fmt.Fprint(w, "Hello world!")
19
}
20
-func main() {
- http.HandleFunc("/", handler)
- http.ListenAndServe(":8080", nil)
21
+func goodbyeHandler(w http.ResponseWriter, r *http.Request) {
22
+ fmt.Fprint(w, "Goodbye world!")
23
0 commit comments