Fix AutoCert() panic issue.

I forgot to catch the http request error, this might cause an unrecoverable panic.
This commit is contained in:
0xJacky 2022-05-06 14:59:18 +08:00
parent 9d3f35b380
commit 0fe9bf56d6
5 changed files with 19 additions and 14 deletions

View file

@ -1,6 +1,6 @@
{
"name": "nginx-ui-frontend",
"version": "1.2.0",
"version": "1.2.2",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",

View file

@ -6,6 +6,11 @@
<meta content="width=device-width,initial-scale=1.0,user-scalable=0" name="viewport">
<link href="<%= BASE_URL %>favicon.ico" rel="icon">
<title><%= htmlWebpackPlugin.options.title %></title>
<style type="text/css">
body {
width: 100% !important;
}
</style>
</head>
<body>
<noscript>

View file

@ -1 +1 @@
{"version":"1.2.0","build_id":8,"total_build":48}
{"version":"1.2.2","build_id":1,"total_build":49}

View file

@ -24,22 +24,17 @@ type ValidError struct {
Message string
}
var trans ut.Translator
func init() {
uni := ut.New(zh.New())
trans, _ = uni.GetTranslator("zh")
v, ok := binding.Validator.Engine().(*val.Validate)
if ok {
_ = zhTranslations.RegisterDefaultTranslations(v, trans)
}
}
func BindAndValid(c *gin.Context, target interface{}) bool {
errs := make(map[string]string)
err := c.ShouldBindJSON(target)
if err != nil {
log.Println("raw err", err)
uni := ut.New(zh.New())
trans, _ := uni.GetTranslator("zh")
v, ok := binding.Validator.Engine().(*val.Validate)
if ok {
_ = zhTranslations.RegisterDefaultTranslations(v, trans)
}
verrs, ok := err.(val.ValidationErrors)

View file

@ -14,7 +14,12 @@ import (
func CertInfo(c *gin.Context) {
domain := c.Param("domain")
key := tool.GetCertInfo(domain)
key, err := tool.GetCertInfo(domain)
if err != nil {
ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"subject_name": key.Subject.CommonName,