Commit 1ec05e3 1 parent c9a73fb commit 1ec05e3 Copy full SHA for 1ec05e3
File tree 2 files changed +16
-18
lines changed
2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change 7
7
"os"
8
8
"runtime"
9
9
10
- "github.com/labstack/echo"
11
- "github.com/labstack/echo/middleware"
12
-
13
10
"github.com/traPtitech/anke-to/model"
14
11
"github.com/traPtitech/anke-to/tuning"
15
12
)
@@ -44,18 +41,6 @@ func main() {
44
41
db .LogMode (true )
45
42
}
46
43
47
- e := echo .New ()
48
- e .Use (middleware .CORSWithConfig (middleware.CORSConfig {
49
- AllowOrigins : []string {"http://localhost:8080" },
50
- AllowCredentials : true ,
51
- }))
52
-
53
- // Middleware
54
- e .Use (middleware .Recover ())
55
- e .Use (middleware .Logger ())
56
-
57
- SetRouting (e )
58
-
59
44
if env == "pprof" {
60
45
runtime .SetBlockProfileRate (1 )
61
46
go func () {
@@ -64,6 +49,6 @@ func main() {
64
49
}
65
50
66
51
port := os .Getenv ("PORT" )
67
- // Start server
68
- e . Logger . Fatal ( e . Start ( port ) )
52
+
53
+ SetRouting ( port )
69
54
}
Original file line number Diff line number Diff line change @@ -2,10 +2,21 @@ package main
2
2
3
3
import (
4
4
"github.com/labstack/echo"
5
+ "github.com/labstack/echo/middleware"
5
6
)
6
7
7
8
// SetRouting ルーティングの設定
8
- func SetRouting (e * echo.Echo ) {
9
+ func SetRouting (port string ) {
10
+ e := echo .New ()
11
+ e .Use (middleware .CORSWithConfig (middleware.CORSConfig {
12
+ AllowOrigins : []string {"http://localhost:8080" },
13
+ AllowCredentials : true ,
14
+ }))
15
+
16
+ // Middleware
17
+ e .Use (middleware .Recover ())
18
+ e .Use (middleware .Logger ())
19
+
9
20
api := InjectAPIServer ()
10
21
11
22
// Static Files
@@ -68,4 +79,6 @@ func SetRouting(e *echo.Echo) {
68
79
apiResults .GET ("/:questionnaireID" , api .GetResults )
69
80
}
70
81
}
82
+
83
+ e .Logger .Fatal (e .Start (port ))
71
84
}
You can’t perform that action at this time.
0 commit comments