-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
2,593 additions
and
2,146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2022-2024 caixw | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:generate web locale -l=und -m -f=yaml ./ | ||
//go:generate web update-locale -src=./locales/und.yaml -dest=./locales/zh-Hans.yaml | ||
|
||
//go:generate web doc -d ./ | ||
//go:generate web restdoc -d ./ | ||
|
||
// Package cmfx 基于 <https://github.com/issue9/web> 框架的一些通用模块 | ||
package cmfx | ||
|
||
// # restdoc cmfx 文档 | ||
// | ||
// @media application/json application/xml | ||
// @version [Version] | ||
// @tag admin 管理员端 | ||
// @tag rbac RBAC | ||
// @openapi github.com/issue9/[email protected] misc/openapi.yaml | ||
// @resp 4XX * #/components/schemas/github.com.issue9.web.Problem | ||
// @resp 5XX * #/components/schemas/github.com.issue9.web.Problem | ||
// @resp 4XX * github.com/issue9/web.Problem | ||
// @resp 5XX * github.com/issue9/web.Problem desc | ||
|
||
import ( | ||
"fmt" | ||
|
@@ -32,7 +34,7 @@ const Version = "0.7.0" | |
// 依次执行 f 中的函数,碰到第一个返回错误的函数时即退出整个流程,并执行 cleanup 进行清理操作。 | ||
// | ||
// cleanup 清理操作,只有当 f 出错时,才会执行 cleanup。 | ||
func Init(s *web.Server, cleanup func(), f ...func() error) { | ||
func Init(s web.Server, cleanup func(), f ...func() error) { | ||
for _, ff := range f { | ||
if err := ff(); err != nil { | ||
if cleanup != nil { | ||
|
@@ -41,7 +43,7 @@ func Init(s *web.Server, cleanup func(), f ...func() error) { | |
|
||
var msg any | ||
if ls, ok := err.(web.LocaleStringer); ok { | ||
msg = ls.LocaleString(s.LocalePrinter()) | ||
msg = ls.LocaleString(s.Locale().Printer()) | ||
} else { | ||
msg = err | ||
} | ||
|
Oops, something went wrong.