패키지 이름 정리

This commit is contained in:
2023-06-27 19:03:53 +09:00
parent 265ae0ac8b
commit 31782578f4
2 changed files with 45 additions and 45 deletions

View File

@ -18,7 +18,7 @@ import (
"time" "time"
"unsafe" "unsafe"
common "repositories.action2quare.com/ayo/gocommon" "repositories.action2quare.com/ayo/gocommon"
"repositories.action2quare.com/ayo/gocommon/flagx" "repositories.action2quare.com/ayo/gocommon/flagx"
"repositories.action2quare.com/ayo/gocommon/logger" "repositories.action2quare.com/ayo/gocommon/logger"
@ -37,17 +37,17 @@ var devflag = flagx.Bool("dev", false, "")
var noauth = flagx.Bool("noauth", false, "") var noauth = flagx.Bool("noauth", false, "")
var ( var (
CollectionLink = common.CollectionName("link") CollectionLink = gocommon.CollectionName("link")
CollectionAuth = common.CollectionName("auth") CollectionAuth = gocommon.CollectionName("auth")
CollectionWhitelist = common.CollectionName("whitelist") CollectionWhitelist = gocommon.CollectionName("whitelist")
CollectionService = common.CollectionName("service") CollectionService = gocommon.CollectionName("service")
CollectionAccount = common.CollectionName("account") CollectionAccount = gocommon.CollectionName("account")
CollectionFile = common.CollectionName("file") CollectionFile = gocommon.CollectionName("file")
CollectionBlock = common.CollectionName("block") CollectionBlock = gocommon.CollectionName("block")
CollectionPlatformLoginToken = common.CollectionName("platform_login_token") //-- 각 플랫폼에 로그인 및 권한 받아오는 과정에 사용하는 Key CollectionPlatformLoginToken = gocommon.CollectionName("platform_login_token") //-- 각 플랫폼에 로그인 및 권한 받아오는 과정에 사용하는 Key
CollectionUserToken = common.CollectionName("usertoken") CollectionUserToken = gocommon.CollectionName("usertoken")
CollectionGamepotUserInfo = common.CollectionName("gamepot_userinfo") //-- 클라로부터 수집된 gamepot 정보 - server to server로 유효성이 검증되진 않았지만 수집은 한다. CollectionGamepotUserInfo = gocommon.CollectionName("gamepot_userinfo") //-- 클라로부터 수집된 gamepot 정보 - server to server로 유효성이 검증되진 않았지만 수집은 한다.
CollectionFirebaseUserInfo = common.CollectionName("firebase_userinfo") //-- Firebase UserInfo CollectionFirebaseUserInfo = gocommon.CollectionName("firebase_userinfo") //-- Firebase UserInfo
) )
const ( const (
@ -72,10 +72,10 @@ func SessionTTL() time.Duration {
} }
type mongoAuthCell struct { type mongoAuthCell struct {
src *common.Authinfo src *gocommon.Authinfo
} }
func (ac *mongoAuthCell) ToAuthinfo() *common.Authinfo { func (ac *mongoAuthCell) ToAuthinfo() *gocommon.Authinfo {
if ac.src == nil { if ac.src == nil {
logger.Error("mongoAuthCell ToAuthinfo failed. ac.src is nil") logger.Error("mongoAuthCell ToAuthinfo failed. ac.src is nil")
} }
@ -87,15 +87,15 @@ func (ac *mongoAuthCell) ToBytes() []byte {
return bt return bt
} }
func makeAuthCollection(mongoClient common.MongoClient, sessionTTL time.Duration) *common.AuthCollection { func makeAuthCollection(mongoClient gocommon.MongoClient, sessionTTL time.Duration) *gocommon.AuthCollection {
authcoll := common.MakeAuthCollection(sessionTTL) authcoll := gocommon.MakeAuthCollection(sessionTTL)
authcoll.SessionRemoved = func(sk string) { authcoll.SessionRemoved = func(sk string) {
skid, _ := primitive.ObjectIDFromHex(sk) skid, _ := primitive.ObjectIDFromHex(sk)
mongoClient.Delete(CollectionAuth, bson.M{ mongoClient.Delete(CollectionAuth, bson.M{
"sk": skid, "sk": skid,
}) })
} }
authcoll.QuerySession = func(sk string, token string) common.AuthinfoCell { authcoll.QuerySession = func(sk string, token string) gocommon.AuthinfoCell {
skid, _ := primitive.ObjectIDFromHex(sk) skid, _ := primitive.ObjectIDFromHex(sk)
var outcell mongoAuthCell var outcell mongoAuthCell
err := mongoClient.FindOneAs(CollectionAuth, bson.M{ err := mongoClient.FindOneAs(CollectionAuth, bson.M{
@ -152,16 +152,16 @@ func (ga *globalAdmins) parse() {
parsed[admin] = true parsed[admin] = true
} }
ga.emails = parsed ga.emails = parsed
ga.modtime = common.ConfigModTime() ga.modtime = gocommon.ConfigModTime()
} }
// Maingate : // Maingate :
type Maingate struct { type Maingate struct {
maingateConfig maingateConfig
mongoClient common.MongoClient mongoClient gocommon.MongoClient
auths *common.AuthCollection auths *gocommon.AuthCollection
//services servicelist //services servicelist
serviceptr unsafe.Pointer serviceptr unsafe.Pointer
admins unsafe.Pointer admins unsafe.Pointer
@ -178,12 +178,12 @@ type Maingate struct {
// New : // New :
func New(ctx context.Context) (*Maingate, error) { func New(ctx context.Context) (*Maingate, error) {
var config maingateConfig var config maingateConfig
if err := common.LoadConfig(&config); err != nil { if err := gocommon.LoadConfig(&config); err != nil {
return nil, err return nil, err
} }
var admins globalAdmins var admins globalAdmins
if err := common.LoadConfig(&admins); err == nil { if err := gocommon.LoadConfig(&admins); err == nil {
admins.parse() admins.parse()
} }
@ -291,7 +291,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
} }
// redis에서 env를 가져온 후에 // redis에서 env를 가져온 후에
mg.mongoClient, err = common.NewMongoClient(context, mg.Mongo, "maingate") mg.mongoClient, err = gocommon.NewMongoClient(context, mg.Mongo, "maingate")
if err != nil { if err != nil {
return err return err
} }
@ -397,7 +397,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
} }
logger.Println("saving files :", pre.Link) logger.Println("saving files :", pre.Link)
var fulldoc fileDocumentDesc var fulldoc FileDocumentDesc
err = mg.mongoClient.FindOneAs(CollectionFile, bson.M{ err = mg.mongoClient.FindOneAs(CollectionFile, bson.M{
"_id": pre.Id, "_id": pre.Id,
}, &fulldoc) }, &fulldoc)
@ -490,9 +490,9 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
} }
logger.Println("Service is registered :", mg.service().ServiceCode) logger.Println("Service is registered :", mg.service().ServiceCode)
serveMux.Handle(common.MakeHttpHandlerPattern(prefix, mg.service().ServiceCode, "/"), mg.service()) serveMux.Handle(gocommon.MakeHttpHandlerPattern(prefix, mg.service().ServiceCode, "/"), mg.service())
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "api/"), mg.api) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "api/"), mg.api)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "query/"), mg.query) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "query/"), mg.query)
configraw, _ := json.Marshal(mg.maingateConfig) configraw, _ := json.Marshal(mg.maingateConfig)
var convertedConfig map[string]any var convertedConfig map[string]any
@ -500,7 +500,7 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
return err return err
} }
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "config"), func(w http.ResponseWriter, r *http.Request) { serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "config"), func(w http.ResponseWriter, r *http.Request) {
defer func() { defer func() {
s := recover() s := recover()
if s != nil { if s != nil {
@ -534,29 +534,29 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
} }
fsx := http.FileServer(http.Dir("./console")) fsx := http.FileServer(http.Dir("./console"))
serveMux.Handle(common.MakeHttpHandlerPattern(prefix, "console/"), http.StripPrefix("/console/", fsx)) serveMux.Handle(gocommon.MakeHttpHandlerPattern(prefix, "console/"), http.StripPrefix("/console/", fsx))
ssx := http.FileServer(http.Dir("./static")) ssx := http.FileServer(http.Dir("./static"))
serveMux.Handle(common.MakeHttpHandlerPattern(prefix, "static/"), http.StripPrefix("/static/", ssx)) serveMux.Handle(gocommon.MakeHttpHandlerPattern(prefix, "static/"), http.StripPrefix("/static/", ssx))
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformGoogle), mg.platform_google_get_login_url) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformGoogle), mg.platform_google_get_login_url)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformGoogle), mg.platform_google_authorize) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformGoogle), mg.platform_google_authorize)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformGoogle), mg.platform_google_authorize_result) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformGoogle), mg.platform_google_authorize_result)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformMicrosoft), mg.platform_microsoft_get_login_url) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformMicrosoft), mg.platform_microsoft_get_login_url)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformMicrosoft), mg.platform_microsoft_authorize) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformMicrosoft), mg.platform_microsoft_authorize)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformMicrosoft), mg.platform_microsoft_authorize_result) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformMicrosoft), mg.platform_microsoft_authorize_result)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformTwitter), mg.platform_twitter_get_login_url) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformTwitter), mg.platform_twitter_get_login_url)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformTwitter), mg.platform_twitter_authorize) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformTwitter), mg.platform_twitter_authorize)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformTwitter), mg.platform_twitter_authorize_result) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformTwitter), mg.platform_twitter_authorize_result)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformApple), mg.platform_apple_get_login_url) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformApple), mg.platform_apple_get_login_url)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformApple), mg.platform_apple_authorize) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformApple), mg.platform_apple_authorize)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformApple), mg.platform_apple_authorize_result) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformApple), mg.platform_apple_authorize_result)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformFirebaseAuth), mg.platform_firebaseauth_get_login_url) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformFirebaseAuth), mg.platform_firebaseauth_get_login_url)
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize_sdk", AuthPlatformFirebaseAuth), mg.platform_firebaseauth_authorize_sdk) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_sdk", AuthPlatformFirebaseAuth), mg.platform_firebaseauth_authorize_sdk)
go mg.watchServiceCollection(ctx, serveMux, prefix) go mg.watchServiceCollection(ctx, serveMux, prefix)
go mg.watchFileCollection(ctx, serveMux, prefix) go mg.watchFileCollection(ctx, serveMux, prefix)

View File

@ -42,7 +42,7 @@ type filePipelineDocument struct {
DocumentKey struct { DocumentKey struct {
Id primitive.ObjectID `bson:"_id"` Id primitive.ObjectID `bson:"_id"`
} `bson:"documentKey"` } `bson:"documentKey"`
File *fileDocumentDesc `bson:"fullDocument"` File *FileDocumentDesc `bson:"fullDocument"`
} }
type whilelistPipelineDocument struct { type whilelistPipelineDocument struct {