From e356fc9514f8179f8624eb797cfb33f9d946940d Mon Sep 17 00:00:00 2001 From: bruce Date: Mon, 12 Jun 2023 10:29:22 +0800 Subject: [PATCH] feat(all): add types.Configuration. --- {logger => components/logger}/logger.go | 0 .../translations}/en_US.go | 0 .../translations}/translation.go | 0 .../translations}/zh_CN.go | 0 .../types/application.go | 2 +- service/types/configuration.go | 17 +++++ uzsdk.go | 17 ++--- version.go | 63 +++++++++++++++++++ 8 files changed, 91 insertions(+), 8 deletions(-) rename {logger => components/logger}/logger.go (100%) rename {translations => service/translations}/en_US.go (100%) rename {translations => service/translations}/translation.go (100%) rename {translations => service/translations}/zh_CN.go (100%) rename application.go => service/types/application.go (94%) create mode 100644 service/types/configuration.go diff --git a/logger/logger.go b/components/logger/logger.go similarity index 100% rename from logger/logger.go rename to components/logger/logger.go diff --git a/translations/en_US.go b/service/translations/en_US.go similarity index 100% rename from translations/en_US.go rename to service/translations/en_US.go diff --git a/translations/translation.go b/service/translations/translation.go similarity index 100% rename from translations/translation.go rename to service/translations/translation.go diff --git a/translations/zh_CN.go b/service/translations/zh_CN.go similarity index 100% rename from translations/zh_CN.go rename to service/translations/zh_CN.go diff --git a/application.go b/service/types/application.go similarity index 94% rename from application.go rename to service/types/application.go index 5c3dd03..f282258 100644 --- a/application.go +++ b/service/types/application.go @@ -1,6 +1,6 @@ // Copyright 2023 nanzoom.com. All Rights Reserved. -package uzsdk +package types // Application defines structure of application's information. type Application struct { diff --git a/service/types/configuration.go b/service/types/configuration.go new file mode 100644 index 0000000..a7f39f9 --- /dev/null +++ b/service/types/configuration.go @@ -0,0 +1,17 @@ +// Copyright 2010-2022 nanzoom.com. All Rights Reserved. + +package types + +// Configuration defines application's configuration. +type Configuration struct { + Service struct { + IP string // server listen address:ip, default: 0.0.0.0 + Port int64 // server listen address:port, default: 9000 + ServerName string // local address served by this server, default: http://[IP]:[Port], exp: http://127.0.0.1:9000 + SystemName string // smartsystem address served by httpd, default: http://[IP], exp: http://192.168.0.6 + PublicName string // smartcloud address served by httpd, default: [ServerName], exp: http://192.168.0.6:8080 + ServicePath string // urlpath for this service, default: /wservice + DataDirectory string // server data directory, default: /data/cloud + TrustedProxies []string // a list of proxies trusted, default: ["127.0.0.1"] + } +} diff --git a/uzsdk.go b/uzsdk.go index 10f9edf..fe6e0ed 100644 --- a/uzsdk.go +++ b/uzsdk.go @@ -3,8 +3,9 @@ package uzsdk import ( - "git.uzoombox.com/git/uzsdk/logger" - "git.uzoombox.com/git/uzsdk/translations" + "git.uzoombox.com/git/uzsdk/components/logger" + "git.uzoombox.com/git/uzsdk/service/translations" + "git.uzoombox.com/git/uzsdk/service/types" "github.com/gin-gonic/gin" "github.com/jmoiron/sqlx" ) @@ -111,7 +112,8 @@ type ResResultList struct { // Respcode returns a structure of Respnode that message has been translated using language if options.language is set, // else directly returns Respcode(code, ct.AdLanguage). // options will be [language]: -// language *string: name of language. +// +// language *string: name of language. func Respcode(code string, options ...interface{}) Respnode { var language *string = nil for _, option := range options { @@ -129,8 +131,9 @@ func Respcode(code string, options ...interface{}) Respnode { // Instance is the framework's instance, used for server & plugin both. type Instance struct { - Db *sqlx.DB // the first database connection created by main routine. - Logger *logger.Logger // logger created by main routine. - Router *gin.Engine // default webservice engine created by main routine. - Maintenance bool // when maintenance mode is true, only serve api /config. + Conf *types.Configuration // configuration of this application. + Db *sqlx.DB // the first database connection created by main routine. + Logger *logger.Logger // logger created by main routine. + Router *gin.Engine // default webservice engine created by main routine. + Maintenance bool // when maintenance mode is true, only serve api /config. } diff --git a/version.go b/version.go index 58a559b..42b77fd 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,67 @@ // Copyright 2023 nanzoom.com. All Rights Reserved. +/* ## Package versions +go 1.20 + +require ( + git.uzoombox.com/git/uzsdk v0.1.0 + github.com/cavaliergopher/grab/v3 v3.0.1 + github.com/chromedp/cdproto v0.0.0-20230611221135-4cd95c996604 + github.com/chromedp/chromedp v0.9.1 + github.com/cstockton/go-conv v1.0.0 + github.com/fatih/structs v1.1.0 + github.com/gin-contrib/gzip v0.0.6 + github.com/gin-gonic/gin v1.9.1 + github.com/huandu/go-sqlbuilder v1.21.0 + github.com/jmoiron/sqlx v1.3.5 + github.com/json-iterator/go v1.1.12 + github.com/lib/pq v1.10.9 + github.com/mafredri/cdp v0.34.1 + github.com/pdfcpu/pdfcpu v0.4.1 + github.com/spaolacci/murmur3 v1.1.0 + github.com/wechatpay-apiv3/wechatpay-go v0.2.16 + golang.org/x/sys v0.8.0 +) + +require ( + github.com/bytedance/sonic v1.9.1 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/chromedp/sysutil v1.0.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/gobwas/httphead v0.1.0 // indirect + github.com/gobwas/pool v0.2.1 // indirect + github.com/gobwas/ws v1.1.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/hhrutter/lzw v1.0.0 // indirect + github.com/hhrutter/tiff v1.0.0 // indirect + github.com/huandu/xstrings v1.3.2 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect + golang.org/x/arch v0.3.0 // indirect + golang.org/x/crypto v0.9.0 // indirect + golang.org/x/image v0.5.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) +*/ package uzsdk -- 2.43.5