This commit is contained in:
crusader 2018-03-21 20:42:06 +09:00
parent 920f9f8c30
commit 25bb9aca92
5 changed files with 18 additions and 13 deletions

View File

@ -1,7 +1,6 @@
package main package main
const ( const (
ConfigPathFlagName = "config-dir"
ConfigFileName = "config.json" ConfigFileName = "config.json"
GRPCUserIDKey = "GRPCUserID" GRPCUserIDKey = "GRPCUserID"

View File

@ -1,8 +1,6 @@
package grpc package grpc
import ( import (
"fmt"
"google.golang.org/grpc" "google.golang.org/grpc"
cgp "git.loafle.net/commons_go/grpc_pool" cgp "git.loafle.net/commons_go/grpc_pool"
@ -23,7 +21,7 @@ func ExternalInit() {
grpcPool = cgp.New(ph) grpcPool = cgp.New(ph)
if err := grpcPool.Start(); nil != err { if err := grpcPool.Start(); nil != err {
logging.Logger().Panic(fmt.Sprintf("App: %v", err)) logging.Logger().Panicf("App: %v", err)
return return
} }
} }

18
main.go
View File

@ -6,6 +6,7 @@ import (
cc "git.loafle.net/commons_go/config" cc "git.loafle.net/commons_go/config"
"git.loafle.net/commons_go/cors_fasthttp" "git.loafle.net/commons_go/cors_fasthttp"
"git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/logging"
oocc "git.loafle.net/overflow/overflow_commons_go/config"
"git.loafle.net/overflow/overflow_server_app/config" "git.loafle.net/overflow/overflow_server_app/config"
"git.loafle.net/overflow/overflow_server_app/external" "git.loafle.net/overflow/overflow_server_app/external"
"git.loafle.net/overflow/overflow_server_app/module/member" "git.loafle.net/overflow/overflow_server_app/module/member"
@ -14,14 +15,21 @@ import (
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
) )
func init() { var (
configPath := flag.String(ConfigPathFlagName, "./", "The path of config file") configDir *string
logConfigPath *string
)
func init() {
configDir = oocc.FlagConfigDir("./")
logConfigPath = oocc.FlagLogConfigFilePath("")
flag.Parse() flag.Parse()
cc.SetConfigPath(*configPath) logging.InitializeLogger(*logConfigPath)
if err := cc.Load(&config.Config, ConfigFileName); nil != err {
panic(err) cc.SetConfigPath(*configDir)
if err := cc.Load(&config.Config, oocc.ConfigFileName); nil != err {
logging.Logger().Panic(err)
} }
} }

View File

@ -4,10 +4,10 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
"net/url" "net/url"
"strings" "strings"
"git.loafle.net/commons_go/logging"
"git.loafle.net/overflow/overflow_server_app/external/grpc" "git.loafle.net/overflow/overflow_server_app/external/grpc"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
) )
@ -30,7 +30,7 @@ func ResetPassword(ctx *fasthttp.RequestCtx) {
length := len(webParams) length := len(webParams)
if length < 0 { if length < 0 {
fmt.Println("eeee") logging.Logger().Errorf("eeee")
} }
jsonMap := webParams[0].(map[string]interface{}) jsonMap := webParams[0].(map[string]interface{})
@ -49,6 +49,6 @@ func ResetPassword(ctx *fasthttp.RequestCtx) {
r, err := grpc.Exec(gRPCCtx, "MemberService.resetPassword", grpcParams) r, err := grpc.Exec(gRPCCtx, "MemberService.resetPassword", grpcParams)
ctx.SetContentType("application/javascript") ctx.SetContentType("application/javascript")
log.Printf("M:%s", r) logging.Logger().Debugf("M:%s", r)
ctx.SetBody([]byte(r)) ctx.SetBody([]byte(r))
} }

View File

@ -164,7 +164,7 @@ func SigninByCookie(ctx *fasthttp.RequestCtx) {
var ok bool var ok bool
var claims jwt.MapClaims var claims jwt.MapClaims
if claims, ok = token.Claims.(jwt.MapClaims); !ok || !token.Valid { if claims, ok = token.Claims.(jwt.MapClaims); !ok || !token.Valid {
logging.Logger().Warn(fmt.Sprintf("Webapp: Token is not valid %v", token)) logging.Logger().Warnf("Webapp: Token is not valid %v", token)
err = errors.New("authToken is invalid") err = errors.New("authToken is invalid")
commons.SendRESTError(ctx, fasthttp.StatusBadRequest, err) commons.SendRESTError(ctx, fasthttp.StatusBadRequest, err)