import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "hello world")
}
func goodbyeHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "goodbye world")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/hello", helloHandler).Methods("GET")
r.HandleFunc("/goodbye", goodbyeHandler).Methods("GET")
http.Handle("/", r)
http.ListenAndServe(":8000", nil)
}
reference:
No comments:
Post a Comment