代码拉取完成,页面将自动刷新
package iris_container
import (
"fmt"
"gitee.com/kristas/booting-go/framework"
. "gitee.com/kristas/booting-go/framework/bean/bean_factory"
"gitee.com/kristas/booting-go/framework/common/tool/browser"
"github.com/kataras/iris/v12"
"github.com/sirupsen/logrus"
"strings"
)
func init() {
framework.Application().Use(new(IrisStarter))
}
type IrisStarter struct {
Log *logrus.Logger `bean:"log"`
IrisConfig iris.Configuration `value:"iris"`
Logging framework.Logging `value:"logging"`
IrisApp *iris.Application `bean:"iris_app"`
}
func (r *IrisStarter) Bean() string {
return "web_container"
}
func (r *IrisStarter) AfterPropertiesSet() {
RegisterIrisApp(r.Logging.Level)
}
func (r *IrisStarter) ListenAndServe(port int) {
if framework.OpenBrowser {
browser.Open(fmt.Sprintf("http://localhost:%d", port))
}
r.Log.Fatal(
r.IrisApp.Listen(
fmt.Sprintf(":%d", port),
iris.WithConfiguration(r.IrisConfig),
),
)
}
func RegisterIrisApp(loggingLevel string) {
app := iris.New()
app.Logger().SetLevel(irisLevelAdapter(loggingLevel))
RegisterWithName("iris_app", app)
}
func irisLevelAdapter(level string) string {
switch strings.ToLower(level) {
case "panic":
return "fatal"
case "trace":
return "debug"
default:
return level
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。