Skip to content

Commit 10e8cf2

Browse files
author
SeungyoungYang
committed
Add api routing
1 parent 73c2ae0 commit 10e8cf2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

api/index.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package api
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/labstack/echo/v4"
7+
)
8+
9+
func Index(c echo.Context) error {
10+
return c.String(http.StatusOK, "Hello, World!")
11+
}

main.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package main
22

33
import (
4-
"net/http"
5-
64
"github.com/labstack/echo/v4"
75
"github.com/labstack/echo/v4/middleware"
6+
7+
"github.com/SeungyoungYang/Go-dev/api"
88
)
99

1010
func main() {
@@ -16,13 +16,8 @@ func main() {
1616
e.Use(middleware.Recover())
1717

1818
// Routes
19-
e.GET("/", hello)
19+
e.GET("/", api.Index)
2020

2121
// Start server
2222
e.Logger.Fatal(e.Start(":1323"))
2323
}
24-
25-
// Handler
26-
func hello(c echo.Context) error {
27-
return c.String(http.StatusOK, "Hello, World!")
28-
}

0 commit comments

Comments
 (0)