Skip to content

Commit

Permalink
fix: server.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj319 committed Dec 25, 2023
1 parent 861bda8 commit 9b6bbee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
12 changes: 12 additions & 0 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import (

type HTTP_METHOD int

const (
POST HTTP_METHOD = iota
GET
HEAD
PUT
DELETE
CONNECT
OPTIONS
TRACE
PATCH
)

func (me HTTP_METHOD) String() string {
methodNames := [...]string{
"POST",
Expand Down
18 changes: 9 additions & 9 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ func RandomWithParams(w http.ResponseWriter, r *http.Request) {

func main() {
r := CreateRouter()
r.addRoute("/home", Home)
r.addRoute("/", Index)
r.addRoute("/:anyParam", Hello)
r.addRoute("/home/:somePath", HomeSomePath)
r.addRoute("/random", Random)
r.addRoute("/random/:params", RandomWithParams)
r.addRoute("/:somePath/asdf/:nothing", HomeSomePath2)
r.addRoute("/file/:fileName/:anotherParam", FileNotRandom)
r.addRoute("/file/:fileName/random/:somethingElse", FileRandom)
r.addRoute("/home", Home, GET)
r.addRoute("/", Index, GET)
r.addRoute("/:anyParam", Hello, POST)
r.addRoute("/home/:somePath", HomeSomePath, PATCH)
r.addRoute("/random", Random, PATCH)
r.addRoute("/random/:params", RandomWithParams, DELETE)
r.addRoute("/:somePath/asdf/:nothing", HomeSomePath2, CONNECT)
r.addRoute("/file/:fileName/:anotherParam", FileNotRandom, OPTIONS)
r.addRoute("/file/:fileName/random/:somethingElse", FileRandom, TRACE)

fmt.Println("Started listening on 0.0.0.0:8080")
err := http.ListenAndServe("0.0.0.0:8080", r)
Expand Down

0 comments on commit 9b6bbee

Please sign in to comment.