blob: f4bf4a864ffe16924ddab7e3342afee048468cd8 [file] [log] [blame]
ktimoney8ead72a2022-04-12 15:10:10 +01001package 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 X509!") // 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}