diff options
| author | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-05-06 12:18:23 -0400 |
|---|---|---|
| committer | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-05-06 12:18:23 -0400 |
| commit | 5c8d644105f7cd95c99577289231d66f6aeda11a (patch) | |
| tree | 90c23c669e7f31d0b0b66375aff88c813b3868e9 | |
| parent | dbfd89805b802356af34dac3df93c19968e8f30e (diff) | |
feat: implement trivial hello-world web server
| -rw-r--r-- | main.go | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -1,5 +1,28 @@ package main +import ( + "io" + "log" + "net/http" +) + +type handler struct{} + +func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + io.WriteString(w, "Hello world!") +} + func main() { + mux := http.NewServeMux() + + mux.Handle("/{$}", &handler{}) + + srv := http.Server{ + Addr: ":8080", + Handler: mux, + } + log.Println("Serving on port 8080...") + log.Fatal(srv.ListenAndServe()) } |
