代码拉取完成,页面将自动刷新
同步操作将从 openEuler/ha-api 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved.
* ha-api licensed under the Mulan Permissive Software License, Version 2.
* See LICENSE file for more details.
* Author: yangzhao_kl <yangzhao1@kylinos.cn>
* Date: Tue Jan 5 09:33:00 2021 +0800
*/
package main
import (
"net/http"
_ "gitee.com/openeuler/ha-api/routers"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/server/web"
"github.com/chai2010/gettext-go"
"gitee.com/openeuler/ha-api/utils"
)
func pageNotFoundHandler(rw http.ResponseWriter, r *http.Request) {
rw.Write([]byte("page not found"))
}
func detectUserLanguage() string {
// Todo: check user language preferences, check environment variables, user profiles, or HTTP request headers
return "zh_CN"
}
func init() {
gettext.BindLocale(gettext.New("ha-api", "locale"))
switch language := detectUserLanguage(); language {
case "zh_CN":
gettext.SetLanguage("zh_CN")
default:
gettext.SetLanguage("zh_CN") // default chinese
}
}
func main() {
logs.SetLogger("console")
logs.SetLevel(logs.LevelNotice)
web.BConfig.CopyRequestBody = true
web.SetStaticPath("/static", "views/static")
// web.SetStaticPath("/4.12.13", "views/static/4.12.13")
// web.SetStaticPath("/static", "views/static/static")
web.BConfig.WebConfig.Session.SessionOn = true
web.BConfig.WebConfig.Session.SessionGCMaxLifetime = 300
web.ErrorHandler("404", pageNotFoundHandler)
port, _ := utils.ReadPortFromConfig()
web.Run(":" + port)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。