mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
add 'Context.IsSSL() bool'
Former-commit-id: 494394ecb3a44dc69d95893eae024efff0ff3612
This commit is contained in:
@@ -400,8 +400,14 @@ type Context interface {
|
||||
IsMobile() bool
|
||||
// IsScript reports whether a client is a script.
|
||||
IsScript() bool
|
||||
// IsSSL reports whether the client is running under HTTPS SSL.
|
||||
//
|
||||
// See `IsHTTP2` too.
|
||||
IsSSL() bool
|
||||
// IsHTTP2 reports whether the protocol version for incoming request was HTTP/2.
|
||||
// The client code always uses either HTTP/1.1 or HTTP/2.
|
||||
//
|
||||
// See `IsSSL` too.
|
||||
IsHTTP2() bool
|
||||
// IsGRPC reports whether the request came from a gRPC client.
|
||||
IsGRPC() bool
|
||||
@@ -1978,10 +1984,28 @@ func (ctx *context) IsScript() bool {
|
||||
return isScriptRegex.MatchString(s)
|
||||
}
|
||||
|
||||
// IsSSL reports whether the client is running under HTTPS SSL.
|
||||
//
|
||||
// See `IsHTTP2` too.
|
||||
func (ctx *context) IsSSL() bool {
|
||||
ssl := strings.EqualFold(ctx.request.URL.Scheme, "https") || ctx.request.TLS != nil
|
||||
if !ssl {
|
||||
for k, v := range ctx.app.ConfigurationReadOnly().GetSSLProxyHeaders() {
|
||||
if ctx.GetHeader(k) == v {
|
||||
ssl = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return ssl
|
||||
}
|
||||
|
||||
// IsHTTP2 reports whether the protocol version for incoming request was HTTP/2.
|
||||
// The client code always uses either HTTP/1.1 or HTTP/2.
|
||||
//
|
||||
// See `IsSSL` too.
|
||||
func (ctx *context) IsHTTP2() bool {
|
||||
return ctx.Request().ProtoMajor == 2
|
||||
return ctx.request.ProtoMajor == 2
|
||||
}
|
||||
|
||||
// IsGRPC reports whether the request came from a gRPC client.
|
||||
|
||||
Reference in New Issue
Block a user