You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
543 B

package main
import (
12 years ago
"fmt"
"net/http"
)
type String string
type Struct struct {
12 years ago
Greeting string
Punct string
Who string
}
func (s String) ServeHTTP(
12 years ago
w http.ResponseWriter,
r *http.Request) {
fmt.Fprintf(w, "%s\n", s)
}
func (s Struct) ServeHTTP(
12 years ago
w http.ResponseWriter,
r *http.Request) {
fmt.Fprintf(w, "%s%s %s", s.Greeting, s.Punct, s.Who)
}
func main() {
12 years ago
http.Handle("/string", String("I'm a frayed knot."))
http.Handle("/struct", &Struct{"Hello", ":", "Gophers!"})
http.ListenAndServe("localhost:4000", nil)
}