diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2023-09-04 14:53:01 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2023-09-04 14:53:01 +0530 |
commit | 0ac23cf0dd872d6d674f6fbc894d3bf3c61697bd (patch) | |
tree | 2ece70e8d440839daed3760273ca667e362b8e46 | |
parent | 75929861ba736aaa92306ded037ca631e38e06fc (diff) |
Initial trial - Hello World greeting w Query
-rw-r--r-- | main.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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, + }) +} |