-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.go
More file actions
31 lines (23 loc) · 660 Bytes
/
Copy pathmain.go
File metadata and controls
31 lines (23 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"fmt"
"net/http"
"github.com/danhawkins/go-vite-react-example/frontend"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
// Create a new echo server
e := echo.New()
// Add standard middleware
e.Use(middleware.Logger())
// Setup the frontend handlers to service vite static assets
frontend.RegisterHandlers(e)
// Setup the API Group
api := e.Group("/api")
// Basic APi endpoint
api.GET("/message", func(c echo.Context) error {
return c.JSON(http.StatusOK, map[string]string{"message": "Hello, from the golang World!"})
})
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", 3000)))
}