QContext
@quik/http / QContext
Abstract Class: QContext<TRequest, TResponse, TUser>
Defined in: http/src/router/endpoint/QContext.ts:63
Base HTTP context wrapping the underlying request and response objects.
Extends
QObject
Type Parameters
TRequest
TRequest extends http.IncomingMessage
TResponse
TResponse extends http.ServerResponse
TUser
Implements
IQContext<TUser>
Constructors
Constructor
new QContext<
TRequest,TResponse,TUser>(request,response):QContext<TRequest,TResponse,TUser>
Defined in: http/src/router/endpoint/QContext.ts:72
Create a new request context wrapper.
Parameters
request
TRequest
response
TResponse
Returns
QContext<TRequest, TResponse, TUser>
Overrides
QObject.constructor
Properties
_authorization?
protectedoptional_authorization?:IQAuthorizationInformation
Defined in: http/src/router/endpoint/QContext.ts:173
_body
protected_body:ObjectLiteral
Defined in: http/src/router/endpoint/QContext.ts:135
_custom
protected_custom:Record<string,any> ={}
Defined in: http/src/router/endpoint/QContext.ts:67
_files
protected_files:Record<string,ObjectLiteral[]>
Defined in: http/src/router/endpoint/QContext.ts:145
_headers
protected_headers:Record<string,string> ={}
Defined in: http/src/router/endpoint/QContext.ts:105
_ip
protected_ip:string
Defined in: http/src/router/endpoint/QContext.ts:211
_language
protected_language:string
Defined in: http/src/router/endpoint/QContext.ts:201
_method
protected_method:string
Defined in: http/src/router/endpoint/QContext.ts:95
_path
protected_path:Record<string,string>
Defined in: http/src/router/endpoint/QContext.ts:159
_query
protected_query:Record<string,string|string[]>
Defined in: http/src/router/endpoint/QContext.ts:125
_request
protected_request:TRequest
Defined in: http/src/router/endpoint/QContext.ts:231
_requestId
protected_requestId:string
Defined in: http/src/router/endpoint/QContext.ts:115
_response
protected_response:TResponse
Defined in: http/src/router/endpoint/QContext.ts:241
_url
protected_url:URL
Defined in: http/src/router/endpoint/QContext.ts:251
_user
protected_user:TUser
Defined in: http/src/router/endpoint/QContext.ts:183
_userAgent
protected_userAgent:string
Defined in: http/src/router/endpoint/QContext.ts:221
Accessors
authorization
Get Signature
get authorization():
IQAuthorizationInformation
Defined in: http/src/router/endpoint/QContext.ts:175
Returns
Set Signature
set authorization(
value):void
Defined in: http/src/router/endpoint/QContext.ts:179
Parameters
value
Returns
void
Implementation of
body
Get Signature
get body():
ObjectLiteral
Defined in: http/src/router/endpoint/QContext.ts:137
Returns
ObjectLiteral
Set Signature
set body(
body):void
Defined in: http/src/router/endpoint/QContext.ts:141
Parameters
body
ObjectLiteral
Returns
void
Implementation of
files
Get Signature
get files():
Record<string,ObjectLiteral[]>
Defined in: http/src/router/endpoint/QContext.ts:147
Returns
Record<string, ObjectLiteral[]>
Set Signature
set files(
files):void
Defined in: http/src/router/endpoint/QContext.ts:155
Parameters
files
Record<string, ObjectLiteral[]>
Returns
void
Implementation of
headers
Get Signature
get headers():
Record<string,string>
Defined in: http/src/router/endpoint/QContext.ts:107
Returns
Record<string, string>
Set Signature
set headers(
value):void
Defined in: http/src/router/endpoint/QContext.ts:111
Parameters
value
Record<string, string>
Returns
void
Implementation of
ip
Get Signature
get ip():
string
Defined in: http/src/router/endpoint/QContext.ts:213
Returns
string
Set Signature
set ip(
value):void
Defined in: http/src/router/endpoint/QContext.ts:217
Parameters
value
string
Returns
void
Implementation of
language
Get Signature
get language():
string
Defined in: http/src/router/endpoint/QContext.ts:203
Returns
string
Set Signature
set language(
lang):void
Defined in: http/src/router/endpoint/QContext.ts:207
Parameters
lang
string
Returns
void
Implementation of
logger
Get Signature
get
protectedlogger():IQLogger
Defined in: core/src/QObject.ts:15
The logger getter for the object.
Returns
IQLogger
Inherited from
QObject.logger
method
Get Signature
get method():
string
Defined in: http/src/router/endpoint/QContext.ts:97
Returns
string
Set Signature
set method(
value):void
Defined in: http/src/router/endpoint/QContext.ts:101
Parameters
value
string
Returns
void
Implementation of
name
Get Signature
get name():
string
Defined in: core/src/QObject.ts:8
Returns
string
Inherited from
QObject.name
page
Get Signature
get page():
string
Defined in: http/src/router/endpoint/QContext.ts:169
Returns
string
Implementation of
path
Get Signature
get path():
Record<string,string>
Defined in: http/src/router/endpoint/QContext.ts:161
Returns
Record<string, string>
Set Signature
set path(
path):void
Defined in: http/src/router/endpoint/QContext.ts:165
Parameters
path
Record<string, string>
Returns
void
Implementation of
query
Get Signature
get query():
Record<string,string|string[]>
Defined in: http/src/router/endpoint/QContext.ts:127
Returns
Record<string, string | string[]>
Set Signature
set query(
value):void
Defined in: http/src/router/endpoint/QContext.ts:131
Parameters
value
Record<string, string | string[]>
Returns
void
Implementation of
request
Get Signature
get
protectedrequest():TRequest
Defined in: http/src/router/endpoint/QContext.ts:233
Returns
TRequest
Set Signature
set
protectedrequest(request):void
Defined in: http/src/router/endpoint/QContext.ts:237
Parameters
request
TRequest
Returns
void
requestId
Get Signature
get requestId():
string
Defined in: http/src/router/endpoint/QContext.ts:117
Returns
string
Set Signature
set requestId(
value):void
Defined in: http/src/router/endpoint/QContext.ts:121
Parameters
value
string
Returns
void
Implementation of
response
Get Signature
get
protectedresponse():TResponse
Defined in: http/src/router/endpoint/QContext.ts:243
Returns
TResponse
Set Signature
set
protectedresponse(response):void
Defined in: http/src/router/endpoint/QContext.ts:247
Parameters
response
TResponse
Returns
void
scheme
Get Signature
get scheme():
string
Defined in: http/src/router/endpoint/QContext.ts:197
Returns
string
Implementation of
token
Get Signature
get token():
string
Defined in: http/src/router/endpoint/QContext.ts:193
Returns
string
Implementation of
url
Get Signature
get
protectedurl():URL
Defined in: http/src/router/endpoint/QContext.ts:253
Returns
URL
Set Signature
set
protectedurl(value):void
Defined in: http/src/router/endpoint/QContext.ts:257
Parameters
value
URL
Returns
void
user
Get Signature
get user():
TUser
Defined in: http/src/router/endpoint/QContext.ts:185
Returns
TUser
Set Signature
set user(
user):void
Defined in: http/src/router/endpoint/QContext.ts:189
Parameters
user
TUser
Returns
void
Implementation of
userAgent
Get Signature
get userAgent():
string
Defined in: http/src/router/endpoint/QContext.ts:223
Returns
string
Set Signature
set userAgent(
value):void
Defined in: http/src/router/endpoint/QContext.ts:227
Parameters
value
string
Returns
void
Implementation of
Methods
clearCookie()
abstractclearCookie(cookieName,options?):void
Defined in: http/src/router/endpoint/QContext.ts:316
Remove a cookie from the current response.
Parameters
cookieName
string
Cookie name to remove
options?
Cookie options applied by the HTTP adapter
Returns
void
Implementation of
endSpan()
protectedendSpan(span):void
Defined in: core/src/QObject.ts:35
End a span returned by startSpan.
Parameters
span
TelemetrySpan
The span to end.
Returns
void
Inherited from
QObject.endSpan
getCookie()
abstractgetCookie(cookieName):string
Defined in: http/src/router/endpoint/QContext.ts:299
Read a cookie value from the current request.
Parameters
cookieName
string
Cookie name to read
Returns
string
Implementation of
getObject()
getObject<
T>(key):T
Defined in: http/src/router/endpoint/QContext.ts:283
Retrieve a custom object stored on the request.
Type Parameters
T
T = any
Parameters
key
string
Returns
T
Implementation of
init()
abstractprotectedinit():void
Defined in: http/src/router/endpoint/QContext.ts:318
Returns
void
logout()
logout():
void
Defined in: http/src/router/endpoint/QContext.ts:271
Log out the current user if possible.
Returns
void
Implementation of
recordSpanError()
protectedrecordSpanError(span,err):void
Defined in: core/src/QObject.ts:45
Record an exception on an active span.
Parameters
span
TelemetrySpan
The span to record the error on.
err
unknown
The error to record.
Returns
void
Inherited from
QObject.recordSpanError
setCookie()
abstractsetCookie(cookieName,cookieValue,options?):void
Defined in: http/src/router/endpoint/QContext.ts:308
Add a cookie to the current response.
Parameters
cookieName
string
Cookie name to write
cookieValue
string
Cookie value to write
options?
Cookie options applied by the HTTP adapter
Returns
void
Implementation of
setObject()
setObject<
T>(key,object):void
Defined in: http/src/router/endpoint/QContext.ts:290
Store a custom object on the request context.
Type Parameters
T
T = any
Parameters
key
string
object
T
Returns
void
Implementation of
setSpanAttribute()
protectedsetSpanAttribute(span,key,value):void
Defined in: core/src/QObject.ts:64
Set a single attribute on an active span.
Parameters
span
TelemetrySpan
The span to update.
key
string
Attribute key.
value
string | number | boolean
Attribute value.
Returns
void
Inherited from
QObject.setSpanAttribute
startSpan()
protectedstartSpan(spanName,options?):TelemetrySpan
Defined in: core/src/QObject.ts:26
Start a telemetry span for the given operation name. Returns undefined when no telemetry provider is active.
Parameters
spanName
string
Name of the span.
options?
TelemetrySpanOptions
Optional span attributes and kind.
Returns
TelemetrySpan
Inherited from
QObject.startSpan
translate()
translate(
key,parameters?):string
Defined in: http/src/router/endpoint/QContext.ts:264
Translate a key using the request bound translator or global i18n.
Parameters
key
string
parameters?
ObjectLiteral
Returns
string