Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (29 sloc) 750 Bytes
package main
import "net/http"
type foo struct{}
func (f foo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
type page struct {
body string
func (p page) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// string is the URL path and http.Handler is any type that has a ServeHTTP method.
type multiplexer map[string]http.Handler
func (m multiplexer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if handler, ok := m[r.RequestURI]; ok {
handler.ServeHTTP(w, r)
} else {
var mux = multiplexer{
"/": foo{},
"/about/": page{"about"},
"/contact/": page{"contact"},
func main() {
http.ListenAndServe(":8000", mux)