Skip to content

Commit

Permalink
feat: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj319 committed Dec 30, 2023
1 parent 30af164 commit 234326a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,39 @@
Another router for the net/http module


## Get Started

```go
package main

import (
"fmt"
"github.com/Neeraj319/nirajan"
"net/http"
)

type Params struct {
Name string // won't work if atribute name does not start with a Capital letter
Age int
}

func Home(w http.ResponseWriter, r *http.Request, params Params) {
response_string := fmt.Sprintf("name: %s age: %d \n", params.Name, params.Age)
fmt.Fprintf(w, response_string)
}


func Index(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "index response")
}

func main() {
r := nirajan.CreateRouter()
r.AddRoute("/:Name/:Age", Home, nirajan.GET)
r.AddRoute("/", Index, nirajan.GET)
http.ListenAndServe("0.0.0.0:8080", r)
}

```

- in the memory of nirajan dhakal (he is not dead)

0 comments on commit 234326a

Please sign in to comment.