url 타입 변경
This commit is contained in:
@ -91,7 +91,9 @@ type DivisionForUser struct {
|
||||
|
||||
type Division struct {
|
||||
DivisionForUser `bson:",inline" json:",inline"`
|
||||
Url string `bson:"url" json:"url"`
|
||||
Url_Deprecated string `bson:"url" json:"url"`
|
||||
Urls bson.M `bson:"urls" json:"urls"`
|
||||
urlsSerialized []byte
|
||||
}
|
||||
|
||||
type serviceDescription struct {
|
||||
@ -177,6 +179,14 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
||||
defaultDivNames[dn] = true
|
||||
}
|
||||
|
||||
if len(div.Url_Deprecated) > 0 && len(div.Urls) == 0 {
|
||||
div.Urls = bson.M{"warehouse": div.Url_Deprecated}
|
||||
}
|
||||
|
||||
div.urlsSerialized, _ = json.Marshal(bson.M{
|
||||
"service": div.Urls,
|
||||
})
|
||||
|
||||
divsForUsers[dn] = &div.DivisionForUser
|
||||
if len(div.State) == 0 {
|
||||
div.State = DivisionState_FullOpen
|
||||
@ -1014,14 +1024,13 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
||||
divname := queryvals.Get("div")
|
||||
divname = strings.Trim(divname, `"`)
|
||||
div := sh.Divisions[divname]
|
||||
var addrresp string
|
||||
var addrresp []byte
|
||||
if div != nil {
|
||||
logger.Println("/addr :", divname, div.State)
|
||||
|
||||
switch div.State {
|
||||
case DivisionState_FullOpen:
|
||||
addrresp = fmt.Sprintf(`{"service":"%s"}`, div.Url)
|
||||
//w.Write([]byte(fmt.Sprintf(`{"service":"%s"}`, div.Url)))
|
||||
addrresp = div.urlsSerialized
|
||||
|
||||
case DivisionState_RestrictedOpen:
|
||||
// 점검중이면 whitelist만 입장 가능
|
||||
@ -1035,12 +1044,9 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
||||
wm := &whitelistmember{Email: authInfo.Email, Platform: authInfo.Platform}
|
||||
if _, ok := sh.wl.get(wm.Key()); ok {
|
||||
// qa 권한이면 입장 가능
|
||||
addrresp = fmt.Sprintf(`{"service":"%s"}`, div.Url)
|
||||
//w.Write([]byte(fmt.Sprintf(`{"service":"%s"}`, div.Url)))
|
||||
addrresp = div.urlsSerialized
|
||||
} else if div.Maintenance != nil {
|
||||
// 권한이 없으므로 공지
|
||||
addrresp = fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link)
|
||||
//w.Write([]byte(fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link)))
|
||||
} else {
|
||||
logger.Println("div.Maintenance is nil :", divname)
|
||||
}
|
||||
@ -1049,14 +1055,13 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
||||
// 점검중. 아무도 못들어감
|
||||
if div.Maintenance != nil {
|
||||
logger.Println("/addr :", divname, div.State, *div.Maintenance)
|
||||
addrresp = fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link)
|
||||
//w.Write([]byte(fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link)))
|
||||
addrresp = []byte(fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link))
|
||||
} else {
|
||||
logger.Println("div.Maintenance is nil :", divname)
|
||||
}
|
||||
}
|
||||
logger.Println("/addr resp :", addrresp)
|
||||
w.Write([]byte(addrresp))
|
||||
logger.Println("/addr resp :", string(addrresp))
|
||||
w.Write(addrresp)
|
||||
} else {
|
||||
logger.Println("div is not found :", divname, sh.Divisions)
|
||||
logger.Println("check maingate database 'service.divisions' :", config.Mongo)
|
||||
|
||||
Reference in New Issue
Block a user