forked from xesina/golang-echo-realworld-example-app
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
44 lines (33 loc) · 1.05 KB
/
main.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
package main
import (
"github.com/xesina/golang-echo-realworld-example-app/db"
"github.com/xesina/golang-echo-realworld-example-app/handler"
"github.com/xesina/golang-echo-realworld-example-app/router"
"github.com/xesina/golang-echo-realworld-example-app/store"
echoSwagger "github.com/swaggo/echo-swagger" // echo-swagger middleware
_ "github.com/xesina/golang-echo-realworld-example-app/docs" // docs is generated by Swag CLI, you have to import it.
)
// @title Swagger Example API
// @version 1.0
// @description Conduit API
// @title Conduit API
// @host 127.0.0.1:8585
// @BasePath /api
// @schemes http https
// @produce application/json
// @consumes application/json
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
r := router.New()
r.GET("/swagger/*", echoSwagger.WrapHandler)
v1 := r.Group("/api")
d := db.New()
db.AutoMigrate(d)
us := store.NewUserStore(d)
as := store.NewArticleStore(d)
h := handler.NewHandler(us, as)
h.Register(v1)
r.Logger.Fatal(r.Start("127.0.0.1:8585"))
}