diff --git a/README.md b/README.md index acc0d1d1..16304c57 100644 --- a/README.md +++ b/README.md @@ -316,13 +316,12 @@ release/paopao-ce --no-default-features --features sqlite3,localoss,loggerfile,r 目前支持的功能集合: | 功能项 | 类别 | 状态 | 备注 | | ----- | ----- | ----- | ----- | -|`OldWeb` | 子服务 | 稳定(默认) | 开启旧的Web服务 | |`Web` | 子服务 | WIP | 开启Web服务| |`Admin` | 子服务 | WIP | 开启Admin后台运维服务| |`SpaceX` | 子服务 | WIP | 开启SpaceX服务| |`Bot` | 子服务 | WIP | 开启Bot服务| |`NativeOBS` | 子服务 | WIP | 开启NativeOBS服务| -|`Deprecated:Web` | 子服务 | 稳定 | Deprecated(关闭) OldWeb服务| +|`Deprecated:Web` | 子服务 | 稳定 | 开启旧的Web服务| |`Gorm` | 数据库 | 稳定(默认) | 使用[gorm](https://github.com/go-gorm/gorm)作为数据库的ORM,默认使用 `Gorm` + `MySQL`组合| |`Sqlx`| 数据库 | WIP | 使用[sqlx](https://github.com/jmoiron/sqlx)作为数据库的ORM| |`MySQL`| 数据库 | 稳定(默认) | 使用MySQL作为数据库| diff --git a/config.yaml.sample b/config.yaml.sample index 30535257..73cf89db 100644 --- a/config.yaml.sample +++ b/config.yaml.sample @@ -12,14 +12,14 @@ Server: # 服务设置 ReadTimeout: 60 WriteTimeout: 60 Features: - Default: ["Base", "MySQL", "Option", "Zinc", "LocalOSS", "LoggerFile", "Friendship"] + Default: ["Base", "MySQL", "Option", "Zinc", "LocalOSS", "LoggerFile", "Friendship", "Deprecated"] Develop: ["Base", "MySQL", "BigCacheIndex", "Meili", "Sms", "AliOSS", "LoggerMeili", "OSS:Retention"] Demo: ["Base", "MySQL", "Option", "Zinc", "Sms", "MinIO", "LoggerZinc", "Migration"] Slim: ["Base", "Sqlite3", "LocalOSS", "LoggerFile", "OSS:TempDir"] Base: ["Redis", "PhoneBind"] Docs: ["Docs:OpenAPI"] Deprecated: ["Deprecated:OldWeb"] - Service: ["Admin", "SpaceX", "Bot", "LocalOSS", "Mobile"] + Service: ["Web", "Admin", "SpaceX", "Bot", "LocalOSS", "Mobile"] Option: ["SimpleCacheIndex"] Sms: "SmsJuhe" WebServer: # Web服务 diff --git a/internal/conf/conf.go b/internal/conf/conf.go index 35755f04..6a994e01 100644 --- a/internal/conf/conf.go +++ b/internal/conf/conf.go @@ -105,8 +105,6 @@ func setupSetting(suite []string, noDefault bool) error { } JWTSetting.Expire *= time.Second - ServerSetting.ReadTimeout *= time.Second - ServerSetting.WriteTimeout *= time.Second SimpleCacheIndexSetting.CheckTickDuration *= time.Second SimpleCacheIndexSetting.ExpireTickDuration *= time.Second BigCacheIndexSetting.ExpireInSecond *= time.Second diff --git a/internal/conf/settting.go b/internal/conf/settting.go index 0c543706..93443f64 100644 --- a/internal/conf/settting.go +++ b/internal/conf/settting.go @@ -270,6 +270,14 @@ func (s *Setting) featuresInfoFrom(k string) (map[string][]string, map[string]st return suites, kv } +func (s *HttpServerSettingS) GetReadTimeout() time.Duration { + return s.ReadTimeout * time.Second +} + +func (s *HttpServerSettingS) GetWriteTimeout() time.Duration { + return s.WriteTimeout * time.Second +} + func (s *MySQLSettingS) Dsn() string { return fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=%t&loc=Local", s.UserName, diff --git a/internal/servants/base/base.go b/internal/servants/base/base.go index acc33bd6..7cf2ffeb 100644 --- a/internal/servants/base/base.go +++ b/internal/servants/base/base.go @@ -37,7 +37,7 @@ type BaseRender types.Empty type JsonResp struct { Code int `json:"code"` Msg string `json:"msg,omitempty"` - Data any `json:",omitempty"` + Data any `json:"data,omitempty"` } type UserSetter interface { diff --git a/internal/servants/web/loose.go b/internal/servants/web/loose.go index 4b04ad36..9e9b1bff 100644 --- a/internal/servants/web/loose.go +++ b/internal/servants/web/loose.go @@ -35,7 +35,7 @@ type looseRender struct { *api.UnimplementedLooseRender } -func (s *looseSrv) BindTimeline(c *gin.Context) (*web.TimelineReq, mir.Error) { +func (s *looseBinding) BindTimeline(c *gin.Context) (*web.TimelineReq, mir.Error) { user, _ := base.UserFrom(c) page, pageSize := app.GetPageInfo(c) v := &web.TimelineReq{ diff --git a/internal/service/admin.go b/internal/service/admin.go index 52bd120b..04ae090e 100644 --- a/internal/service/admin.go +++ b/internal/service/admin.go @@ -82,8 +82,8 @@ func newAdminService() Service { server: &http.Server{ Addr: addr, Handler: engine, - ReadTimeout: conf.AdminServerSetting.ReadTimeout, - WriteTimeout: conf.AdminServerSetting.WriteTimeout, + ReadTimeout: conf.AdminServerSetting.GetReadTimeout(), + WriteTimeout: conf.AdminServerSetting.GetWriteTimeout(), MaxHeaderBytes: 1 << 20, }, } diff --git a/internal/service/bot.go b/internal/service/bot.go index d1cb4ea7..3c9b2f4d 100644 --- a/internal/service/bot.go +++ b/internal/service/bot.go @@ -82,8 +82,8 @@ func newBotService() Service { server: &http.Server{ Addr: addr, Handler: engine, - ReadTimeout: conf.BotServerSetting.ReadTimeout, - WriteTimeout: conf.BotServerSetting.WriteTimeout, + ReadTimeout: conf.BotServerSetting.GetReadTimeout(), + WriteTimeout: conf.BotServerSetting.GetWriteTimeout(), MaxHeaderBytes: 1 << 20, }, } diff --git a/internal/service/localoss.go b/internal/service/localoss.go index 7d70291d..5bead183 100644 --- a/internal/service/localoss.go +++ b/internal/service/localoss.go @@ -57,8 +57,8 @@ func newLocalossService() Service { server: &http.Server{ Addr: addr, Handler: engine, - ReadTimeout: conf.LocalossServerSetting.ReadTimeout, - WriteTimeout: conf.LocalossServerSetting.WriteTimeout, + ReadTimeout: conf.LocalossServerSetting.GetReadTimeout(), + WriteTimeout: conf.LocalossServerSetting.GetWriteTimeout(), MaxHeaderBytes: 1 << 20, }, } diff --git a/internal/service/service.go b/internal/service/service.go index 957979c3..21375631 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -58,12 +58,11 @@ func MaxSidSize(ss []Service) int { } func newService() (ss []Service) { - // add oldWebService if not depredcated OldWebService - cfg.Not("Deprecated:OldWeb", func() { - ss = append(ss, newOldWebService()) - }) // add all service if declared in features on config.yaml cfg.In(cfg.Actions{ + "Deprecated:OldWeb": func() { + ss = append(ss, newOldWebService()) + }, "Web": func() { ss = append(ss, newWebService()) }, diff --git a/internal/service/space.go b/internal/service/space.go index 2d5ff1ff..5cce8914 100644 --- a/internal/service/space.go +++ b/internal/service/space.go @@ -82,8 +82,8 @@ func newSpaceXService() Service { server: &http.Server{ Addr: addr, Handler: engine, - ReadTimeout: conf.SpaceXServerSetting.ReadTimeout, - WriteTimeout: conf.SpaceXServerSetting.WriteTimeout, + ReadTimeout: conf.SpaceXServerSetting.GetReadTimeout(), + WriteTimeout: conf.SpaceXServerSetting.GetWriteTimeout(), MaxHeaderBytes: 1 << 20, }, } diff --git a/internal/service/web.go b/internal/service/web.go index 0d1b9f12..a0c821a0 100644 --- a/internal/service/web.go +++ b/internal/service/web.go @@ -82,12 +82,13 @@ func newWebService() Service { server: &http.Server{ Addr: addr, Handler: engine, - ReadTimeout: conf.WebServerSetting.ReadTimeout, - WriteTimeout: conf.WebServerSetting.WriteTimeout, + ReadTimeout: conf.WebServerSetting.GetReadTimeout(), + WriteTimeout: conf.WebServerSetting.GetWriteTimeout(), MaxHeaderBytes: 1 << 20, }, } }) + return &webService{ baseHttpService: &baseHttpService{ server: server, diff --git a/internal/service/web_old.go b/internal/service/web_old.go index bcef11cd..beb3902c 100644 --- a/internal/service/web_old.go +++ b/internal/service/web_old.go @@ -49,8 +49,8 @@ func newOldWebService() Service { server: &http.Server{ Addr: addr, Handler: engine, - ReadTimeout: conf.ServerSetting.ReadTimeout, - WriteTimeout: conf.ServerSetting.WriteTimeout, + ReadTimeout: conf.ServerSetting.GetReadTimeout(), + WriteTimeout: conf.ServerSetting.GetWriteTimeout(), MaxHeaderBytes: 1 << 20, }, } diff --git a/main.go b/main.go index 5e0fcc01..d1886084 100644 --- a/main.go +++ b/main.go @@ -99,6 +99,6 @@ func main() { wg.Wait() } else { - fmt.Fprintf(color.Output, "no service need start so just exit") + fmt.Fprintln(color.Output, "no service need start so just exit") } }