-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.go
45 lines (35 loc) · 1002 Bytes
/
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
package main
import (
"net/http"
"github.com/byuoitav/authmiddleware"
"github.com/byuoitav/common"
"github.com/byuoitav/common/log"
"github.com/byuoitav/couch-db-repl/handlers"
"github.com/byuoitav/couch-db-repl/replication"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main() {
port := ":7012"
router := common.NewRouter()
router.Pre(middleware.RemoveTrailingSlash())
router.Use(middleware.CORS())
// Use the `secure` routing group to require authentication
secure := router.Group("", echo.WrapMiddleware(authmiddleware.Authenticate))
secure.PUT("/log-level/:level", log.SetLogLevel)
secure.GET("/log-level", log.GetLogLevel)
secure.GET("/replication/start", handlers.ReplicateNow)
server := &http.Server{
Addr: port,
MaxHeaderBytes: 1024 * 10,
}
go func() {
if err := router.StartServer(server); err != nil {
log.L.Fatal(err)
}
}()
replication.Init()
if err := replication.Start(); err != nil {
log.L.Fatal(err)
}
}