summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-05-06 12:18:23 -0400
committerBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-05-06 12:18:23 -0400
commit5c8d644105f7cd95c99577289231d66f6aeda11a (patch)
tree90c23c669e7f31d0b0b66375aff88c813b3868e9
parentdbfd89805b802356af34dac3df93c19968e8f30e (diff)
feat: implement trivial hello-world web server
-rw-r--r--main.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/main.go b/main.go
index 7905807..3512c24 100644
--- a/main.go
+++ b/main.go
@@ -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())
}