From 34df46e0d5a341ec62d23c96610b0de5a402574c Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Wed, 31 Jul 2024 16:41:56 -0400 Subject: [PATCH] Revert back to using http.Handler type for the router This reverts commit 0afafd97fdb24a031dc12e39a5c860a669e694d0. --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 02a11c0..3833cc4 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,9 @@ func contactHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "

Contact Page

To get in touch, email me at example@example.com

") } -var pathHandler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) { +type Router struct{} + +func (router Router) ServeHTTP(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/": homeHandler(w, r) @@ -29,6 +31,7 @@ var pathHandler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) } func main() { + var router Router fmt.Println("Starting the server on :3000...") - http.ListenAndServe(":3000", pathHandler) + http.ListenAndServe(":3000", router) }