From 234326a1ed9efb76c94a9a66ac086cffe7828677 Mon Sep 17 00:00:00 2001 From: Neeraj319 Date: Sat, 30 Dec 2023 14:26:01 +0545 Subject: [PATCH] feat: update readme --- README.MD | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.MD b/README.MD index 183e3c2..083fda4 100644 --- a/README.MD +++ b/README.MD @@ -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)