go-ddns-svc/route/api/api.go
2019-05-03 17:17:44 +08:00

24 lines
458 B
Go

package api
import (
"net/textproto"
"git.trj.tw/golang/go-ddns-svc/module/config"
"git.trj.tw/golang/go-ddns-svc/module/context"
)
// VerifyPrivate -
func VerifyPrivate(c *context.Context) {
privateHeader := c.Request.Header.Get(textproto.CanonicalMIMEHeaderKey("x-mtfos-key"))
if len(privateHeader) == 0 {
c.Forbidden(nil)
return
}
conf := config.GetConfig()
if privateHeader != conf.VerifyValue {
c.Forbidden(nil)
return
}
c.Next()
}