Skip to content

Commit

Permalink
配置修改
Browse files Browse the repository at this point in the history
  • Loading branch information
Away0x committed Aug 9, 2019
1 parent 34fa505 commit fd4771d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
APP_NAME = "echo_shop"
PROXY = "https://goproxy.io"
# PROXY = "https://mirrors.aliyun.com/goproxy/"
# PROXY = "https://athens.azurefd.net/"
# PROXY = "https://proxy.golang.org/"

default:
go build -o ${APP_NAME}
# env GOOS=linux GOARCH=amd64 go build -o ${APP_NAME}

install:
env GOPROXY=https://goproxy.io go mod download
env GOPROXY=${PROXY} go mod download

c-test:
env ECHO_SHOP_APP_RUNMODE=test go test -v ./test/controllers/...
Expand Down
7 changes: 4 additions & 3 deletions app/context/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ func (a *AppContext) RenderHTML(tplName string, data ...serializer.Data) error {

// RenderJSON resp json
func (a *AppContext) RenderJSON(code int, data CommonResponse) error {
r := map[string]interface{}{}
r := map[string]interface{}{
"code": data.Code,
"msg": data.Msg,
}

r["code"] = data.Code
r["msg"] = data.Msg
if data.Data != nil {
r["data"] = data.Data
}
Expand Down
5 changes: 3 additions & 2 deletions bootstrap/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ var defaultConfigMap = map[string]interface{}{
// app
"APP.NAME": defaultAppName,
"APP.RUNMODE": "production", // 环境
"APP.ADDR": defaultAppPort,
"APP.PORT": defaultAppPort,
"APP.URL": "http://localhost" + defaultAppPort,
"APP.KEY": "Rtg8BPKNEf2mB4mgvKONGPZZQSaJWNLijxR42qRgq0iBb5",
"APP.TEMP_DIR": defaultTempDir, // 临时文件存储位置 (log ...)
"APP.PUBLIC_DIR": "public", // public 文件夹
"APP.RESOURCES_DIR": "resources", // resources 文件夹
"APP.TEMPLATE_DIR": "resources/views", // 模板文件存放文件夹
"APP.SHOW_ERROR_DETAIL": true, // response 是否会输出错误详情

// https
"TLS.ADDR": ":9001",
"TLS.PORT": ":9001",

// db
"DB.CONNECTION": "mysql",
Expand Down
8 changes: 4 additions & 4 deletions bootstrap/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ func RunEcho() {
keyFile := config.String("TLS.KEY_FILE")
if certFile != "" && keyFile != "" {
go func() {
e.Logger.Fatal(e.StartTLS(config.String("TLS.ADDR"), certFile, keyFile))
e.Logger.Fatal(e.StartTLS(config.String("TLS.PORT"), certFile, keyFile))
}()
}

// 启动 app
e.Logger.Fatal(e.Start(config.String("APP.ADDR")))
e.Logger.Fatal(e.Start(config.String("APP.PORT")))

// graceful -----------------------------------------------
// if config.IsDev() {
// e.Logger.Fatal(e.Start(config.String("APP.ADDR")))
// e.Logger.Fatal(e.Start(config.String("APP.PORT")))
// } else {
// e.Server.Addr = config.String("APP.ADDR")
// e.Server.Addr = config.String("APP.PORT")
// e.Logger.Fatal(gracehttp.Serve(e.Server))
// }
}
Expand Down
2 changes: 1 addition & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
APP:
NAME: echo_shop
RUNMODE: development # 模式: development, production, staging, test
Addr: :9000 # 端口
PORT: :9000 # 端口
URL: http://localhost:9000 # 网站地址
KEY: Rtg8BPKNEf2mB4mgvKONGPZZQSaJWNLijxR42qRgq0iBb5

Expand Down

0 comments on commit fd4771d

Please sign in to comment.