-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_route.go
32 lines (25 loc) · 994 Bytes
/
main_route.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
package main
import (
"github.com/gin-gonic/gin"
"twitter/component/appctx"
"twitter/memcache"
"twitter/middleware"
"twitter/modules/tweet/transport/gintwitter"
"twitter/modules/upload/uploadtransport/ginupload"
"twitter/modules/user/transport/ginuser"
"twitter/modules/user/userstore"
)
func setupRoute(appCtx appctx.AppContext, v1 *gin.RouterGroup) {
userStore := userstore.NewSQLStore(appCtx.GetMyDBConnection())
userCachingStore := memcache.NewUserCaching(memcache.NewCaching(), userStore)
//POST /v1/upload
v1.POST("/upload", middleware.RequireAuth(appCtx, userStore), ginupload.Upload(appCtx))
v1.POST("/register", ginuser.Register(appCtx))
v1.POST("/authenticate", ginuser.Login(appCtx))
v1.GET("/profile", middleware.RequireAuth(appCtx, userStore), ginuser.GetProfile(appCtx))
{
tweets := v1.Group("/tweets")
tweets.POST("", middleware.RequireAuth(appCtx, userCachingStore), gintwitter.CreateTweet(appCtx))
tweets.GET("", gintwitter.ListTweet(appCtx))
}
}