summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-09-04 14:53:01 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-09-04 14:53:01 +0530
commit0ac23cf0dd872d6d674f6fbc894d3bf3c61697bd (patch)
tree2ece70e8d440839daed3760273ca667e362b8e46
parent75929861ba736aaa92306ded037ca631e38e06fc (diff)
Initial trial - Hello World greeting w Query
-rw-r--r--main.go10
1 files changed, 10 insertions, 0 deletions
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,
+ })
+}