27 lines
577 B
Go
27 lines
577 B
Go
package controllers
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"server/services"
|
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
)
|
|
|
|
type AcmeChallengeController struct {
|
|
beego.Controller
|
|
}
|
|
|
|
func (c *AcmeChallengeController) Serve() {
|
|
token := strings.TrimSpace(c.Ctx.Input.Param(":token"))
|
|
keyAuth, ok := services.GetHTTP01Challenge(token)
|
|
if !ok {
|
|
c.Ctx.Output.SetStatus(404)
|
|
_ = c.Ctx.Output.Body([]byte("not found"))
|
|
return
|
|
}
|
|
c.Ctx.Output.Header("Content-Type", "text/plain; charset=utf-8")
|
|
c.Ctx.Output.Header("Cache-Control", "no-store")
|
|
_ = c.Ctx.Output.Body([]byte(keyAuth))
|
|
}
|