go-ddns-svc/route/api/api.go

24 lines
458 B
Go
Raw Normal View History

2019-05-03 09:17:44 +00:00
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()
}