mirror of
https://github.com/Binject/debug
synced 2026-06-08 10:28:33 +00:00
26 lines
499 B
Go
26 lines
499 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func newPeopleHandler() http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
fmt.Fprintln(w, "This is the people handler.")
|
|
})
|
|
}
|
|
|
|
func main() {
|
|
mux := http.NewServeMux()
|
|
|
|
// Create sample handler to returns 404
|
|
mux.Handle("/resources", http.NotFoundHandler())
|
|
|
|
// Create sample handler that returns 200
|
|
mux.Handle("/resources/people/", newPeopleHandler())
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", mux))
|
|
}
|