Skip to content

Instantly share code, notes, and snippets.

@JenHsuan
Created December 29, 2018 06:11
Show Gist options
  • Save JenHsuan/9656fae28511209ba1a2a59fa596e6e2 to your computer and use it in GitHub Desktop.
Save JenHsuan/9656fae28511209ba1a2a59fa596e6e2 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
)
type car int
func (m car) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Mcleod-Key", "this is from mcleod")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintln(w, "<h1>car</h1>")
}
type plane int
func (m plane) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Mcleod-Key", "this is from mcleod")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintln(w, "<h1>plane</h1>")
}
func main() {
var c car
var p plane
http.Handle("/car", c)
http.Handle("/plane", p)
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment