basic setup for HTTP handling
This commit is contained in:
parent
3138a7f3ef
commit
42dd3fbe83
|
@ -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 {
|
||||
|
||||
//}
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/wgroeneveld/go-jamming/app/index"
|
||||
)
|
||||
|
||||
func (s *server) routes() {
|
||||
s.router.HandleFunc("/", index.HandleIndex)
|
||||
}
|
|
@ -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)
|
||||
}
|
2
go.mod
2
go.mod
|
@ -1,3 +1,5 @@
|
|||
module github.com/wgroeneveld/go-jamming
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/gorilla/mux v1.8.0 // indirect
|
||||
|
|
|
@ -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=
|
Loading…
Reference in New Issue