go-examples/example-httpserver/main.go
2017-07-12 18:37:41 +02:00

24 lines
377 B
Go

package main
import (
"io"
"log"
"net/http"
)
type MyHandler int
func (MyHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("Content-Type", "text/plain")
io.WriteString(resp, req.URL.Path)
}
func main() {
var myHandler = new(MyHandler)
s := &http.Server{
Addr: ":9000",
Handler: myHandler,
}
log.Fatal(s.ListenAndServe())
}