Http server

This commit is contained in:
Meutel 2017-07-12 18:37:41 +02:00
parent 2b1c780df3
commit 28962d2d44
2 changed files with 24 additions and 0 deletions

1
.gitignore vendored
View File

@ -51,3 +51,4 @@ example-redis/example-redis
echorot13/echorot13 echorot13/echorot13
chatserver/chatserver chatserver/chatserver
example-httptcp/example-httptcp example-httptcp/example-httptcp
example-httpserver/example-httpserver

View File

@ -0,0 +1,23 @@
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())
}