Skip to content

Commit

Permalink
Merge pull request #24 from IRONICBo/fix/aggregation-config
Browse files Browse the repository at this point in the history
feat: aggreate config.
  • Loading branch information
Baihhh authored Mar 13, 2024
2 parents da0a873 + 5c5b8c0 commit c434f8c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1,123 deletions.
1 change: 1 addition & 0 deletions cmd/gopcomm/.env_temp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GOP_ACCOUNT_ENDPOINT="0.0.0.0:8081"
GOP_COMMUNITY_ENDPOINT="0.0.0.0:8080"

# Database DSN
GOP_COMMUNITY_DRIVER=
GOP_COMMUNITY_DSN=

# Qiniu Storage
Expand Down
22 changes: 16 additions & 6 deletions cmd/gopcomm/community_yap.gox
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import (
"context"
"fmt"
"flag"
"io"
"net/http"
"net/url"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/goplus/community/internal/core"
"github.com/goplus/community/translation"
_ "github.com/joho/godotenv/autoload"
"github.com/joho/godotenv"
gopaccountsdk "github.com/liuscraft/gop-casdoor-account-sdk"
"github.com/qiniu/x/xlog"
language "golang.org/x/text/language"
Expand All @@ -21,6 +23,8 @@ import (
var (
community *core.Community
trans *translation.Engine
domain string
htmlUrl string
)

const (
Expand All @@ -31,8 +35,6 @@ const (
)

todo := context.TODO()
endpoint := os.Getenv("GOP_COMMUNITY_ENDPOINT")
domain := os.Getenv("GOP_COMMUNITY_DOMAIN")
xLog := xlog.New("")

// Modify / to /static
Expand Down Expand Up @@ -859,15 +861,23 @@ post "/api/article/like", ctx => {
}
}

conf := &core.Config{}
community, _ = core.New(todo, conf)
core.CasdoorConfigInit()

// 404
handle "/", ctx => {
ctx.yap "4xx", {}
}

configFile := ".env"
flag.StringVar(&configFile, "config", ".env", "Path to the config file")
flag.Parse()
if err := godotenv.Load(configFile); err != nil {
xLog.Error(err)
}

conf := core.NewConfigFromEnv()
community, _ = core.New(todo, conf)
domain = conf.QiNiuConfig.Domain
endpoint := conf.AppConfig.EndPoint

xLog.Info "Started in endpoint: ", endpoint

// 500
Expand Down
Loading

0 comments on commit c434f8c

Please sign in to comment.