-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
49 lines (38 loc) · 1.07 KB
/
server.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"net/http"
"time"
"github.com/martinyonathann/bookingapp/controllers"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
e := echo.New()
v1 := e.Group("/v1")
groupRouteHotel(v1)
e.Use(middleware.Recover())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{echo.GET, echo.POST},
}))
e.POST("/login", controllers.LoginController)
e.POST("/registration", controllers.Registration)
e.GET("/profil", controllers.ProfileHandler)
s := &http.Server{
Addr: ":1323",
ReadTimeout: 20 * time.Minute,
WriteTimeout: 20 * time.Minute,
}
e.Logger.Fatal(e.StartServer(s))
}
func groupRouteHotel(e *echo.Group) {
hotel := e.Group("/hotel")
hotel.POST("", controllers.AddHotel)
hotel.POST("/update", controllers.UpdateHotel)
hotel.GET("", controllers.GetAllHotel)
hotel.DELETE("/:id", controllers.DeleteHotel)
}
// func groupRouteBooking (e *echo.Group){
// booking := e.Group("/booking")
// booking.POST("", controllers.CreateBooking)
// }