diff --git a/app/index/handler.go b/app/index/handler.go new file mode 100644 index 0000000..9c55d55 --- /dev/null +++ b/app/index/handler.go @@ -0,0 +1,16 @@ + +package index + +import ( + "net/http" + "fmt" +) + +func HandleIndex(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Printf("testje") +} + +//func (s *server) handleIndex() http.HandlerFunc { + +//} diff --git a/app/routes.go b/app/routes.go new file mode 100644 index 0000000..014b6b6 --- /dev/null +++ b/app/routes.go @@ -0,0 +1,10 @@ + +package app + +import ( + "github.com/wgroeneveld/go-jamming/app/index" +) + +func (s *server) routes() { + s.router.HandleFunc("/", index.HandleIndex) +} diff --git a/app/server.go b/app/server.go new file mode 100644 index 0000000..c899c43 --- /dev/null +++ b/app/server.go @@ -0,0 +1,24 @@ + +package app + +import ( + "fmt" + "net/http" + + "github.com/gorilla/mux" +) + +type server struct { + router *mux.Router +} + +func Start() { + r := mux.NewRouter() + server := &server{router: r} + + server.routes() + http.Handle("/", r) + + fmt.Printf("Serving at port 1337...\n") + http.ListenAndServe(":1337", nil) +} diff --git a/go.mod b/go.mod index 9f224ca..4086a16 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/wgroeneveld/go-jamming go 1.16 + +require github.com/gorilla/mux v1.8.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5350288 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= diff --git a/main.go b/main.go index 79c7630..fe231bc 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,10 @@ package main -import "fmt" +import ( + "github.com/wgroeneveld/go-jamming/app" +) func main() { - fmt.Println("it works!") + app.Start() }