2019-04-25 04:52:08 +07:00
|
|
|
package middlewares
|
|
|
|
|
2021-12-02 09:21:46 +07:00
|
|
|
import (
|
2022-04-03 07:48:26 +07:00
|
|
|
"errors"
|
|
|
|
|
2021-12-02 09:21:46 +07:00
|
|
|
"github.com/valyala/fasthttp"
|
2021-07-22 10:52:37 +07:00
|
|
|
)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
2021-12-02 09:21:46 +07:00
|
|
|
var (
|
|
|
|
headerXForwardedProto = []byte(fasthttp.HeaderXForwardedProto)
|
|
|
|
headerXForwardedHost = []byte(fasthttp.HeaderXForwardedHost)
|
|
|
|
headerXForwardedFor = []byte(fasthttp.HeaderXForwardedFor)
|
|
|
|
headerXRequestedWith = []byte(fasthttp.HeaderXRequestedWith)
|
|
|
|
headerAccept = []byte(fasthttp.HeaderAccept)
|
|
|
|
|
|
|
|
headerXForwardedURI = []byte("X-Forwarded-URI")
|
|
|
|
headerXOriginalURL = []byte("X-Original-URL")
|
|
|
|
headerXForwardedMethod = []byte("X-Forwarded-Method")
|
2022-02-06 20:37:28 +07:00
|
|
|
|
2022-03-04 11:46:12 +07:00
|
|
|
headerVary = []byte(fasthttp.HeaderVary)
|
|
|
|
headerOrigin = []byte(fasthttp.HeaderOrigin)
|
|
|
|
headerAccessControlAllowCredentials = []byte(fasthttp.HeaderAccessControlAllowCredentials)
|
|
|
|
headerAccessControlAllowHeaders = []byte(fasthttp.HeaderAccessControlAllowHeaders)
|
|
|
|
headerAccessControlAllowMethods = []byte(fasthttp.HeaderAccessControlAllowMethods)
|
|
|
|
headerAccessControlAllowOrigin = []byte(fasthttp.HeaderAccessControlAllowOrigin)
|
|
|
|
headerAccessControlMaxAge = []byte(fasthttp.HeaderAccessControlMaxAge)
|
|
|
|
headerAccessControlRequestHeaders = []byte(fasthttp.HeaderAccessControlRequestHeaders)
|
|
|
|
headerAccessControlRequestMethod = []byte(fasthttp.HeaderAccessControlRequestMethod)
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
headerValueFalse = []byte("false")
|
|
|
|
headerValueMaxAge = []byte("100")
|
|
|
|
headerValueVary = []byte("Accept-Encoding, Origin")
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-02-06 20:37:28 +07:00
|
|
|
protoHTTPS = []byte("https")
|
|
|
|
protoHTTP = []byte("http")
|
|
|
|
|
|
|
|
// UserValueKeyBaseURL is the User Value key where we store the Base URL.
|
|
|
|
UserValueKeyBaseURL = []byte("base_url")
|
2021-07-22 10:52:37 +07:00
|
|
|
)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
2021-07-22 10:52:37 +07:00
|
|
|
const (
|
2021-12-02 09:21:46 +07:00
|
|
|
headerValueXRequestedWithXHR = "XMLHttpRequest"
|
|
|
|
contentTypeApplicationJSON = "application/json"
|
|
|
|
contentTypeTextHTML = "text/html"
|
2021-07-22 10:52:37 +07:00
|
|
|
)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
|
|
|
var okMessageBytes = []byte("{\"status\":\"OK\"}")
|
|
|
|
|
2021-07-22 10:52:37 +07:00
|
|
|
const (
|
|
|
|
messageOperationFailed = "Operation failed"
|
|
|
|
messageIdentityVerificationTokenAlreadyUsed = "The identity verification token has already been used"
|
|
|
|
messageIdentityVerificationTokenHasExpired = "The identity verification token has expired"
|
|
|
|
)
|
2021-05-05 05:06:05 +07:00
|
|
|
|
|
|
|
var protoHostSeparator = []byte("://")
|
2022-04-03 07:48:26 +07:00
|
|
|
|
|
|
|
var errPasswordPolicyNoMet = errors.New("the supplied password does not met the security policy")
|