mg.config를 config로 변경

This commit is contained in:
2023-12-06 16:35:55 +09:00
parent dab5a35870
commit 2e60fac840
7 changed files with 51 additions and 52 deletions

View File

@ -127,8 +127,6 @@ func (ga *globalAdmins) parse() {
// Maingate : // Maingate :
type Maingate struct { type Maingate struct {
maingateConfig
mongoClient gocommon.MongoClient mongoClient gocommon.MongoClient
sessionProvider session.Provider sessionProvider session.Provider
@ -146,9 +144,10 @@ type Maingate struct {
firebaseAppContext context.Context firebaseAppContext context.Context
} }
var config maingateConfig
// New : // New :
func New(ctx context.Context) (*Maingate, error) { func New(ctx context.Context) (*Maingate, error) {
var config maingateConfig
if err := gocommon.LoadConfig(&config); err != nil { if err := gocommon.LoadConfig(&config); err != nil {
return nil, err return nil, err
} }
@ -167,7 +166,6 @@ func New(ctx context.Context) (*Maingate, error) {
} }
mg := Maingate{ mg := Maingate{
maingateConfig: config,
admins: unsafe.Pointer(&admins), admins: unsafe.Pointer(&admins),
tokenEndpoints: make(map[string]string), tokenEndpoints: make(map[string]string),
authorizationEndpoints: make(map[string]string), authorizationEndpoints: make(map[string]string),
@ -181,7 +179,7 @@ func New(ctx context.Context) (*Maingate, error) {
} }
if !*noauth { if !*noauth {
opt := option.WithCredentialsFile(mg.FirebaseAdminSDKCredentialFile) opt := option.WithCredentialsFile(config.FirebaseAdminSDKCredentialFile)
firebaseApp, err := firebase.NewApp(context.Background(), nil, opt) firebaseApp, err := firebase.NewApp(context.Background(), nil, opt)
if err != nil { if err != nil {
logger.Error("firebase admin error initializing app failed :", err) logger.Error("firebase admin error initializing app failed :", err)
@ -265,7 +263,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
} }
// redis에서 env를 가져온 후에 // redis에서 env를 가져온 후에
mg.mongoClient, err = gocommon.NewMongoClient(context, mg.Mongo) mg.mongoClient, err = gocommon.NewMongoClient(context, config.Mongo)
if err != nil { if err != nil {
return logger.ErrorWithCallStack(err) return logger.ErrorWithCallStack(err)
} }
@ -320,7 +318,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
return logger.ErrorWithCallStack(err) return logger.ErrorWithCallStack(err)
} }
if err = mg.mongoClient.MakeExpireIndex(CollectionPlatformLoginToken, int32(mg.SessionTTL+300)); err != nil { if err = mg.mongoClient.MakeExpireIndex(CollectionPlatformLoginToken, int32(config.SessionTTL+300)); err != nil {
return logger.ErrorWithCallStack(err) return logger.ErrorWithCallStack(err)
} }
@ -342,7 +340,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
return logger.ErrorWithCallStack(err) return logger.ErrorWithCallStack(err)
} }
mg.sessionProvider, err = session.NewProviderWithConfig(context, mg.SessionConfig) mg.sessionProvider, err = session.NewProviderWithConfig(context, config.SessionConfig)
if err != nil { if err != nil {
return logger.ErrorWithCallStack(err) return logger.ErrorWithCallStack(err)
} }
@ -461,7 +459,7 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
}) })
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "api/"), mg.api) serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "api/"), mg.api)
configraw, _ := json.Marshal(mg.maingateConfig) configraw, _ := json.Marshal(config)
var convertedConfig map[string]any var convertedConfig map[string]any
if err := json.Unmarshal(configraw, &convertedConfig); err != nil { if err := json.Unmarshal(configraw, &convertedConfig); err != nil {
return logger.ErrorWithCallStack(err) return logger.ErrorWithCallStack(err)
@ -613,7 +611,7 @@ func (mg *Maingate) getUserTokenWithCheck(platform string, userid string, brinfo
updatetime, ok := found["lastupdate"].(int64) updatetime, ok := found["lastupdate"].(int64)
if !ok || time.Now().Unix()-updatetime < mg.maingateConfig.Autologin_ttl { if !ok || time.Now().Unix()-updatetime < config.Autologin_ttl {
info.platform = platform info.platform = platform
info.userid = userid info.userid = userid
info.brinfo = brinfo info.brinfo = brinfo
@ -874,14 +872,14 @@ func JWTparseCode(keyurl string, code string) (string, string, string) {
func (mg *Maingate) google_analytics_js(w http.ResponseWriter, r *http.Request) { func (mg *Maingate) google_analytics_js(w http.ResponseWriter, r *http.Request) {
fgaconfig := Firebase_Google_Analytics_JS_SDK_Config{ fgaconfig := Firebase_Google_Analytics_JS_SDK_Config{
FGA_apiKey: mg.FGA_apiKey, FGA_apiKey: config.FGA_apiKey,
FGA_authDomain: mg.FGA_authDomain, FGA_authDomain: config.FGA_authDomain,
FGA_databaseURL: mg.FGA_databaseURL, FGA_databaseURL: config.FGA_databaseURL,
FGA_projectId: mg.FGA_projectId, FGA_projectId: config.FGA_projectId,
FGA_storageBucket: mg.FGA_storageBucket, FGA_storageBucket: config.FGA_storageBucket,
FGA_messagingSenderId: mg.FGA_messagingSenderId, FGA_messagingSenderId: config.FGA_messagingSenderId,
FGA_appId: mg.FGA_appId, FGA_appId: config.FGA_appId,
FGA_measurementId: mg.FGA_measurementId, FGA_measurementId: config.FGA_measurementId,
} }
parsedTemplate, _ := template.ParseFiles("template/fb-ga.min.js") parsedTemplate, _ := template.ParseFiles("template/fb-ga.min.js")
err := parsedTemplate.Execute(w, fgaconfig) err := parsedTemplate.Execute(w, fgaconfig)

View File

@ -95,8 +95,8 @@ func (mg *Maingate) platform_apple_get_login_url(w http.ResponseWriter, r *http.
} }
params := url.Values{} params := url.Values{}
params.Add("client_id", mg.AppleCientId) params.Add("client_id", config.AppleCientId)
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformApple) params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformApple)
params.Add("response_type", "code id_token") params.Add("response_type", "code id_token")
params.Add("scope", "name email") params.Add("scope", "name email")
@ -146,7 +146,7 @@ func (mg *Maingate) platform_apple_authorize(w http.ResponseWriter, r *http.Requ
} }
http.SetCookie(w, &cookie) http.SetCookie(w, &cookie)
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformApple, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다. http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformApple, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
} }
func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *http.Request) { func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *http.Request) {
@ -208,17 +208,17 @@ func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *ht
} }
// Generate the client secret used to authenticate with Apple's validation servers // Generate the client secret used to authenticate with Apple's validation servers
secret, err := generateClientSecret(mg.ApplePrivateKey, mg.AppleTeamId, mg.AppleServiceId, mg.AppleKeyId) secret, err := generateClientSecret(config.ApplePrivateKey, config.AppleTeamId, config.AppleServiceId, config.AppleKeyId)
if err != nil { if err != nil {
logger.Error("error generating secret: ", err) logger.Error("error generating secret: ", err)
return return
} }
vReq := Apple_WebValidationTokenRequest{ vReq := Apple_WebValidationTokenRequest{
ClientID: mg.AppleServiceId, ClientID: config.AppleServiceId,
ClientSecret: secret, ClientSecret: secret,
Code: code, Code: code,
RedirectURI: mg.RedirectBaseUrl + "/authorize/" + AuthPlatformApple, // This URL must be validated with apple in your service RedirectURI: config.RedirectBaseUrl + "/authorize/" + AuthPlatformApple, // This URL must be validated with apple in your service
} }
var resp Apple_ValidationResponse var resp Apple_ValidationResponse
@ -268,14 +268,14 @@ func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *ht
func (mg *Maingate) platform_apple_getuserinfo(refreshToken string) (bool, string, string) { func (mg *Maingate) platform_apple_getuserinfo(refreshToken string) (bool, string, string) {
//=================================RefreshToken을 사용해서 정보 가져 온다. 이미 인증된 사용자의 업데이트 목적 //=================================RefreshToken을 사용해서 정보 가져 온다. 이미 인증된 사용자의 업데이트 목적
secret, err := generateClientSecret(mg.ApplePrivateKey, mg.AppleTeamId, mg.AppleServiceId, mg.AppleKeyId) secret, err := generateClientSecret(config.ApplePrivateKey, config.AppleTeamId, config.AppleServiceId, config.AppleKeyId)
if err != nil { if err != nil {
logger.Error("error generating secret: ", err) logger.Error("error generating secret: ", err)
return false, "", "" return false, "", ""
} }
vReqRefreshToken := Apple_WebRefreshTokenRequest{ vReqRefreshToken := Apple_WebRefreshTokenRequest{
ClientID: mg.AppleServiceId, ClientID: config.AppleServiceId,
ClientSecret: secret, ClientSecret: secret,
RefreshToken: refreshToken, RefreshToken: refreshToken,
} }

View File

@ -84,9 +84,9 @@ func (mg *Maingate) platform_google_get_login_url(w http.ResponseWriter, r *http
} }
params := url.Values{} params := url.Values{}
params.Add("client_id", mg.GoogleClientId) params.Add("client_id", config.GoogleClientId)
params.Add("response_type", "code") params.Add("response_type", "code")
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle) params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email") params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email")
params.Add("access_type", "offline") params.Add("access_type", "offline")
params.Add("prompt", "consent") params.Add("prompt", "consent")
@ -140,7 +140,7 @@ func (mg *Maingate) platform_google_authorize(w http.ResponseWriter, r *http.Req
} }
http.SetCookie(w, &cookie2) http.SetCookie(w, &cookie2)
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformGoogle, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다. http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformGoogle, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
} }
func (mg *Maingate) platform_google_authorize_result(w http.ResponseWriter, r *http.Request) { func (mg *Maingate) platform_google_authorize_result(w http.ResponseWriter, r *http.Request) {
@ -211,9 +211,9 @@ func (mg *Maingate) platform_google_authorize_result(w http.ResponseWriter, r *h
//================= //=================
params := url.Values{} params := url.Values{}
params.Add("client_id", mg.GoogleClientId) params.Add("client_id", config.GoogleClientId)
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle) params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
params.Add("client_secret", mg.GoogleClientSecret) params.Add("client_secret", config.GoogleClientSecret)
params.Add("code", code) params.Add("code", code)
params.Add("grant_type", "authorization_code") params.Add("grant_type", "authorization_code")
@ -285,9 +285,9 @@ func (mg *Maingate) platform_google_getuserinfo(info usertokeninfo) (bool, strin
if time.Now().Unix() > info.accesstoken_expire_time { if time.Now().Unix() > info.accesstoken_expire_time {
params := url.Values{} params := url.Values{}
params.Add("client_id", mg.GoogleClientId) params.Add("client_id", config.GoogleClientId)
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle) params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
params.Add("client_secret", mg.GoogleClientSecret) params.Add("client_secret", config.GoogleClientSecret)
params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email") params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email")
params.Add("refresh_token", info.token) params.Add("refresh_token", info.token)
params.Add("grant_type", "refresh_token") params.Add("grant_type", "refresh_token")

View File

@ -83,9 +83,9 @@ func (mg *Maingate) platform_microsoft_get_login_url(w http.ResponseWriter, r *h
} }
params := url.Values{} params := url.Values{}
params.Add("client_id", mg.MicrosoftClientId) params.Add("client_id", config.MicrosoftClientId)
params.Add("response_type", "code") params.Add("response_type", "code")
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft) params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
params.Add("response_mode", "query") params.Add("response_mode", "query")
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read") params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
@ -127,7 +127,7 @@ func (mg *Maingate) platform_microsoft_authorize(w http.ResponseWriter, r *http.
} }
http.SetCookie(w, &cookie) http.SetCookie(w, &cookie)
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformMicrosoft, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다. http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformMicrosoft, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
} }
func (mg *Maingate) platform_microsoft_authorize_result(w http.ResponseWriter, r *http.Request) { func (mg *Maingate) platform_microsoft_authorize_result(w http.ResponseWriter, r *http.Request) {
@ -191,13 +191,13 @@ func (mg *Maingate) platform_microsoft_authorize_result(w http.ResponseWriter, r
//================= //=================
params := url.Values{} params := url.Values{}
params.Add("client_id", mg.MicrosoftClientId) params.Add("client_id", config.MicrosoftClientId)
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft) params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
params.Add("code", code) params.Add("code", code)
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read") params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
params.Add("grant_type", "authorization_code") params.Add("grant_type", "authorization_code")
params.Add("client_secret", mg.MicrosoftClientSecret) params.Add("client_secret", config.MicrosoftClientSecret)
var respReferesh Microsoft_ValidationResponse var respReferesh Microsoft_ValidationResponse
acceestoken_expire_time := time.Now().Unix() acceestoken_expire_time := time.Now().Unix()
@ -263,13 +263,13 @@ func (mg *Maingate) platform_microsoft_getuserinfo(info usertokeninfo) (bool, st
if time.Now().Unix() > info.accesstoken_expire_time { if time.Now().Unix() > info.accesstoken_expire_time {
params := url.Values{} params := url.Values{}
params.Add("client_id", mg.MicrosoftClientId) params.Add("client_id", config.MicrosoftClientId)
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft) params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
params.Add("refresh_token", info.token) params.Add("refresh_token", info.token)
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read") params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
params.Add("grant_type", "refresh_token") params.Add("grant_type", "refresh_token")
params.Add("client_secret", mg.MicrosoftClientSecret) params.Add("client_secret", config.MicrosoftClientSecret)
var respReferesh Microsoft_ValidationResponse var respReferesh Microsoft_ValidationResponse
acceestoken_expire_time := time.Now().Unix() acceestoken_expire_time := time.Now().Unix()

View File

@ -40,7 +40,7 @@ func (mg *Maingate) platform_steamsdk_authorize(w http.ResponseWriter, r *http.R
} }
if !*noauth { if !*noauth {
err = authenticateSteamUser(mg.SteamPublisherAuthKey, mg.SteamAppId, authinfo.UserSteamId, authinfo.UserAuthToken) err = authenticateSteamUser(config.SteamPublisherAuthKey, config.SteamAppId, authinfo.UserSteamId, authinfo.UserAuthToken)
} }
if err == nil { if err == nil {

View File

@ -123,7 +123,7 @@ func (mg *Maingate) platform_twitter_authorize(w http.ResponseWriter, r *http.Re
} }
http.SetCookie(w, &cookie) http.SetCookie(w, &cookie)
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformTwitter, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다. http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformTwitter, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
} }
func (mg *Maingate) platform_twitter_authorize_result(w http.ResponseWriter, r *http.Request) { func (mg *Maingate) platform_twitter_authorize_result(w http.ResponseWriter, r *http.Request) {
@ -249,7 +249,7 @@ func (mg *Maingate) platform_twitter_getuserinfo(token, secret string) (bool, st
} }
func (mg *Maingate) CallTwitterAPI_WithAPPKey(requesturl, method, nonce string) string { func (mg *Maingate) CallTwitterAPI_WithAPPKey(requesturl, method, nonce string) string {
return mg.CallTwitterAPI(requesturl, method, mg.TwitterOAuthKey, mg.TwitterOAuthSecret, nonce) return mg.CallTwitterAPI(requesturl, method, config.TwitterOAuthKey, config.TwitterOAuthSecret, nonce)
} }
func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret, nonce string) string { func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret, nonce string) string {
@ -272,8 +272,8 @@ func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret
//vals.Add("oauth_callback", "actionclient://callback") //vals.Add("oauth_callback", "actionclient://callback")
//vals.Add("oauth_callback", "http://127.0.0.1:7770/auth") //vals.Add("oauth_callback", "http://127.0.0.1:7770/auth")
vals.Add("oauth_callback", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformTwitter) vals.Add("oauth_callback", config.RedirectBaseUrl+"/authorize/"+AuthPlatformTwitter)
vals.Add("oauth_consumer_key", mg.TwitterCustomerKey) vals.Add("oauth_consumer_key", config.TwitterCustomerKey)
vals.Add("oauth_token", oauth_token) vals.Add("oauth_token", oauth_token)
vals.Add("oauth_signature_method", "HMAC-SHA1") vals.Add("oauth_signature_method", "HMAC-SHA1")
vals.Add("oauth_timestamp", strconv.Itoa(int(time.Now().Unix()))) vals.Add("oauth_timestamp", strconv.Itoa(int(time.Now().Unix())))
@ -282,7 +282,7 @@ func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret
parameterString := strings.Replace(vals.Encode(), "+", "%20", -1) parameterString := strings.Replace(vals.Encode(), "+", "%20", -1)
signatureBase := strings.ToUpper(method) + "&" + url.QueryEscape(strings.Split(requesturl, "?")[0]) + "&" + url.QueryEscape(parameterString) signatureBase := strings.ToUpper(method) + "&" + url.QueryEscape(strings.Split(requesturl, "?")[0]) + "&" + url.QueryEscape(parameterString)
signingKey := url.QueryEscape(mg.TwitterCustomerSecret) + "&" + url.QueryEscape(oauth_secret) signingKey := url.QueryEscape(config.TwitterCustomerSecret) + "&" + url.QueryEscape(oauth_secret)
signature := calculateTwitterSignature(signatureBase, signingKey) signature := calculateTwitterSignature(signatureBase, signingKey)
headerString := "OAuth oauth_callback=\"" + url.QueryEscape(vals.Get("oauth_callback")) + "\", oauth_consumer_key=\"" + url.QueryEscape(vals.Get("oauth_consumer_key")) + "\", oauth_nonce=\"" + url.QueryEscape(vals.Get("oauth_nonce")) + headerString := "OAuth oauth_callback=\"" + url.QueryEscape(vals.Get("oauth_callback")) + "\", oauth_consumer_key=\"" + url.QueryEscape(vals.Get("oauth_consumer_key")) + "\", oauth_nonce=\"" + url.QueryEscape(vals.Get("oauth_nonce")) +

View File

@ -246,10 +246,10 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
defaultMarshaled, _ := json.Marshal(defaultsDivs) defaultMarshaled, _ := json.Marshal(defaultsDivs)
sh.divisionsSplits["default"] = defaultMarshaled sh.divisionsSplits["default"] = defaultMarshaled
sh.MaximumNumLinkAccount = mg.maingateConfig.MaximumNumLinkAccount sh.MaximumNumLinkAccount = config.MaximumNumLinkAccount
sh.mongoClient = mg.mongoClient sh.mongoClient = mg.mongoClient
sh.sessionProvider = mg.sessionProvider sh.sessionProvider = mg.sessionProvider
sh.sessionTTL = time.Duration(mg.SessionTTL * int64(time.Second)) sh.sessionTTL = time.Duration(config.SessionTTL * int64(time.Second))
sh.serviceCodeBytes, _ = hex.DecodeString(sh.ServiceCode) sh.serviceCodeBytes, _ = hex.DecodeString(sh.ServiceCode)
sh.getUserBrowserInfo = mg.GetUserBrowserInfo sh.getUserBrowserInfo = mg.GetUserBrowserInfo
sh.getUserTokenWithCheck = mg.getUserTokenWithCheck sh.getUserTokenWithCheck = mg.getUserTokenWithCheck
@ -812,6 +812,7 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
} }
} else { } else {
logger.Println("div is not found :", divname, sh.Divisions) logger.Println("div is not found :", divname, sh.Divisions)
logger.Println("check maingate database 'service.divisions' :", config.Mongo)
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
} }
} else { } else {