summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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())
}