blob: dc6e7078c9846f38b000ebc43c7f6df9c7d5b48e [file] [log] [blame]
ktimoney6be05292022-03-02 12:53:14 +00001package main
2
3import (
4 "net/http"
5)
6
7// create a handler struct
8type HttpHandler struct{}
9
10// implement `ServeHTTP` method on `HttpHandler` struct
11func (h HttpHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
12 // create response binary data
13 data := []byte("Hello World!") // slice of bytes
14 // write `data` to response
15 res.Write(data)
16}
17
18func main() {
19 // create a new handler
20 handler := HttpHandler{}
21 // listen and serve
22 http.ListenAndServe(":9000", handler)
23}