dnssecsocket/emaild/alfonso.go

47 lines
1022 B
Go

package main
import "fmt"
import "log"
import "net/http"
import "github.com/davecgh/go-spew/spew"
func handler(w http.ResponseWriter, r *http.Request) {
// spew.Dump(r)
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
log.Printf("handler: fucking unknown path")
}
func handler2(w http.ResponseWriter, r *http.Request) {
spew.Dump(r)
fmt.Fprintf(w, "Hi there, handler2 %s!", r.URL.Path[1:])
log.Printf("handler: method switch statement")
switch r.Method {
case http.MethodGet:
// Serve the resource.
log.Printf("handler2 GET")
case http.MethodPost:
// Create a new record.
log.Printf("handler2 POST")
case http.MethodPut:
// Update an existing record.
log.Printf("handler2 PUT")
case http.MethodDelete:
// Remove the record.
log.Printf("handler2 DELETE")
default:
// Give an error message.
log.Printf("handler2 DEFAULT")
}
}
func main() {
log.Println("listen on :9000")
http.HandleFunc("/", handler)
http.HandleFunc("/email", handler2)
http.ListenAndServe(":9000", nil)
}