summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-09-04 19:05:57 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-09-04 19:05:57 +0530
commit1b9421884f3d403e3406e61cee742bd03d3a0fa5 (patch)
tree2d956abc98a3ff3dc84195c3bad5a0aa2268e95b /main.go
parent117d461c4944f189576f0c4967851de458ba6f32 (diff)
Refactoring code
Diffstat (limited to 'main.go')
-rw-r--r--main.go54
1 files changed, 0 insertions, 54 deletions
diff --git a/main.go b/main.go
deleted file mode 100644
index fb9628e..0000000
--- a/main.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package main
-
-import (
- "net/http"
-
- "github.com/labstack/echo/v4"
-
- "fmt"
- "github.com/justsaumit/fis-golang/idgen"
-)
-
-type HelloWorld struct {
- Message string `json:"message"`
-}
-
-func main() {
- e := echo.New()
- e.GET("/hello", Greetings)
- e.GET("/hello/:name", GreetingsWithParams)
- e.GET("/hello-queries", GreetingsWithQuery)
- e.GET("/genid", GenerateIDHandler)
- e.Logger.Fatal(e.Start(":3000"))
-}
-
-func Greetings(c echo.Context) error {
- return c.JSON(http.StatusOK, HelloWorld{
- Message: "Hello World",
- })
-}
-
-func GreetingsWithParams(c echo.Context) error {
- params := c.Param("name")
- return c.JSON(http.StatusOK, HelloWorld{
- Message: "Hello World, my name is " + params,
- })
-}
-
-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,
- })
-}
-
-
-func GenerateIDHandler(c echo.Context) error {
- id := idgen.GenerateID()
- //Print the generated ID to the console.
- fmt.Println("Generated ID:", id)
- return c.JSON(http.StatusOK, map[string]string{"message": "Generated ID: " + id})
- // return c.JSON(http.StatusOK, HelloWorld{
- // Message: "Generated ID: " + id,
- //})
-}