Function: httpRequestOfContext()
httpRequestOfContext(
context):IncomingMessage|undefined
Get the HTTP request carrying a service action's request, when httpServiceEntrypoint serves it (to read its headers, its remote address…).
Parameters
context
The service action's context (this.context in a controller).
Returns
IncomingMessage | undefined
The Node.js HTTP request, or undefined when another adapter serves the request.
Example
typescript
import {Controller, httpRequestOfContext, ServiceContext} from 'lakutata/com/entrypoint'
import {ServiceAction} from 'lakutata/decorator/ctrl'
class WhoAmIController extends Controller {
@ServiceAction({cmd: 'whoami'})
public async whoami(): Promise<string | undefined> {
return httpRequestOfContext(this.context as ServiceContext)?.socket.remoteAddress
}
}