forked from ton-connect/bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.go
More file actions
26 lines (22 loc) · 708 Bytes
/
http.go
File metadata and controls
26 lines (22 loc) · 708 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
package main
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/tonkeeper/bridge/config"
)
func registerHandlers(e *echo.Echo, h *handler) {
bridge := e.Group("/bridge")
if config.Config.CorsEnable {
bridge.GET("/events", h.EventRegistrationHandler, middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET"},
}))
bridge.POST("/message", h.SendMessageHandler, middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{"POST"},
}))
} else {
bridge.GET("/events", h.EventRegistrationHandler)
bridge.POST("/message", h.SendMessageHandler)
}
}