Skip to main content

HTTP Variables

Connection Variables

The following connection variables are available on the conn struct:

NameTypeDescription
conn.ClientIPstringThe source IP of the HTTP connection to the ngrok endpoint.
conn.Geo.CountryCodestringThe two-letter ISO country code based on the client IP.
conn.Geo.LatitudestringThe approximate latitude based on the client IP.
conn.Geo.LatLongRadiusKmstringThe radius in kilometers around the latitude and longitude where the client IP is likely to originate.
conn.Geo.LongitudestringThe approximate longitude based on the client IP.

conn.ClientIP

The source IP of the HTTP connection to the ngrok endpoint as a string.

expressions:
- conn.ClientIP in ['::1', '127.0.0.1']

conn.Geo.CountryCode

The two-letter ISO country code based on the client IP.

expressions:
- conn.Geo.CountryCode != 'US'

conn.Geo.Latitude

The approximate latitude based on the client IP.

expressions:
- double(conn.Geo.Latitude) >= 45.0

conn.Geo.LatLongRadiusKm

The radius in kilometers around the latitude and longitude where the client IP is likely to originate.

expressions:
- conn.Geo.LatLongRadiusKm <= '20'

conn.Geo.Longitude

The approximate longitude based on the client IP.

expressions:
- double(conn.Geo.Longitude) <= -93.0

Request Variables

The following request variables are available on the req struct:

NameTypeDescription
req.ClientTLS.CertCNstringThe subject common name of the client's leaf TLS certificate.
req.ClientTLS.CipherSuitestringThe cipher suite negotiated on the connection.
req.ClientTLS.SNIstringThe Server Name Indication extension sent by the client.
req.ClientTLS.VersionstringThe TLS Version used on the connection.
req.ContentLengthintThe length of the content associated with the request.
req.CookieslistThe list of HTTP cookie objects provided in the request.
req.MethodstringThe request method.
req.URLstringThe URL of the request.
req.PathstringThe Path part of the request URL with a leading slash.
req.ParamsmapThe query parameters of the request URL wherein a string key maps to a list of string values.
req.ProtocolstringThe protocol version of the request.
req.HoststringThe host of the request.
req.LocationstringThe 'Location' header of the request.
req.HeadersmapThe headers of the request wherein a string key maps to a list of string values. Header keys must be written in canonical format.
req.TrailersmapThe trailers of the request wherein a string key maps to a list of string values. Trailer keys must be written in canonical format.

req.ClientTLS.CertCN

The subject common name of the client's leaf TLS certificate.

expressions:
- req.ClientTLS.CertCN.startsWith('example')

req.ClientTLS.CipherSuite

The cipher suite negotiated on the connection.

expressions:
- req.ClientTLS.CipherSuite.contains('SHA256')

req.ClientTLS.SNI

The Server Name Indication extension sent by the client.

expressions:
- req.ClientTLS.SNI.startsWith('domain')

req.ClientTLS.Version

The TLS Version used on the connection.

expressions:
- req.ClientTLS.Version.contains('1.3')

req.ContentLength

The length of the content associated with the request.

expressions:
- req.ContentLength > 10000000

req.Method

The request method.

expressions:
- req.Method == 'POST' || req.Method == 'PUT'

req.Cookies

The list of HTTP cookie objects provided in the request.

expressions:
- size(req.Cookies) > 0

req.URL

The URL of the request.

expressions:
- req.URL.contains('/admin')

req.Path

The Path part of the request URL with a leading slash.

expressions:
- req.Path.startsWith('/foo')

req.Params

The query parameters of the request URL wherein a string key maps to a list of string values.

expressions:
- "'bar' in req.Params['foo']"

req.Protocol

The protocol version of the request.

expressions:
- "`req.Protocol == 'HTTP/1.1'"

req.Host

The host of the request.

expressions:
- req.Host.contains(':8080')

req.Location

The 'Location' header of the request.

expressions:
- req.Location == '/index.html'

req.Headers

The headers of the request wherein a string key maps to a list of string values.

expressions:
- "'Fizz' in req.Headers['Baz']"

req.Trailers

The trailers of the request wherein a string key maps to a list of string values.

expressions:
- "'Fizz' in req.Trailers['Baz']"

Response Variables

The following response variables are available on the res struct:

NameTypeDescription
res.ContentLengthintThe length of the content associated with the response.
res.CookieslistThe list of HTTP cookie objects provided in the response.
res.HeadersmapThe headers of the response wherein a string key maps to a list of string values. Header keys must be written in canonical format.
res.LocationstringThe 'Location' header of the response.
res.ServerTLS.CertCNstringThe subject common name of the leaf TLS certificate.
res.ServerTLS.CipherSuitestringThe cipher suite negotiated on the connection.
res.ServerTLS.SNIstringThe Server Name Indication extension sent by the client.
res.ServerTLS.VersionstringThe TLS Version used on the connection.
res.StatusCodestringThe status code of the response.
res.TrailersmapThe trailers of the response wherein a string key maps to a list of string values. Trailer keys must be written in canonical format.

res.ContentLength

The length of the content associated with the response.

expressions:
- res.ContentLength != 0

res.Cookies

The list of HTTP cookie objects provided in the response.

expressions:
- size(req.Cookies) > 0

res.Headers

The headers of the response wherein a string key maps to a list of string values.

expressions:
- "'Fizz' in res.Headers['Baz']"

res.Location

The 'Location' header of the response.

expressions:
- res.Location == '/index.html'

res.ServerTLS.CertCN

The subject common name of the leaf TLS certificate.

expressions:
- res.ClientTLS.CertCN.startsWith('example')

res.ServerTLS.CipherSuite

The cipher suite negotiated on the connection.

expressions:
- res.ClientTLS.CipherSuite.contains('SHA256')

res.ServerTLS.SNI

The Server Name Indication extension sent by the client.

expressions:
- res.ClientTLS.SNI.startsWith('domain')

res.ServerTLS.Version

The TLS Version used on the connection.

expressions:
- res.ClientTLS.Version.contains('1.3')

res.StatusCode

The status code of the response.

expressions:
- res.StatusCode >= '300'

res.Trailers

The trailers of the response wherein a string key maps to a list of string values.

expressions:
- "'fizz' in res.Trailers['baz']"