From 0ac23cf0dd872d6d674f6fbc894d3bf3c61697bd Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Mon, 4 Sep 2023 14:53:01 +0530 Subject: Initial trial - Hello World greeting w Query --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index ab3f1ca..385d8cc 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ func main() { e := echo.New() e.GET("/hello", Greetings) e.GET("/hello/:name", GreetingsWithParams) + e.GET("/hello-queries", GreetingsWithQuery) e.Logger.Fatal(e.Start(":3000")) } @@ -33,3 +34,12 @@ func GreetingsWithParams(c echo.Context) error { Message: "Hello World, my name is " + params, }) } + +//http://localhost:3000/hello-queries?name=Saumit +//{"message":"Hello World, I'm using queries and my name is Saumit"} +func GreetingsWithQuery(c echo.Context) error { + query := c.QueryParam("name") + return c.JSON(http.StatusOK, HelloWorld{ + Message: "Hello World, I'm using queries and my name is " + query, + }) +} -- cgit v1.2.3