HttpStatusEnhancer
File: http-status.enhancer.ts
Overview
The HttpStatusEnhancer
class is designed to augment error objects with HTTP-specific metadata. This can be valuable for debugging, monitoring, and auditing HTTP-related issues within applications.
Properties
Property | Description |
---|---|
| HTTP Status Code, default is |
| URL where the error occurred, default is an empty string. |
| HTTP Method used (GET, POST, etc.), default is an empty string. |
| HTTP request headers, default is an empty object. |
| HTTP response headers, default is an empty object. |
| Query parameters in the URL, default is an empty object. |
| Body of the HTTP request, default is |
| Body of the HTTP response, default is |
| Client's IP address, default is an empty string. |
| Latency in milliseconds, default is |
Methods
setHttpStatusCode(httpStatusCode: number)
setHttpStatusCode(httpStatusCode: number)
Sets the HTTP status code and validates it against known status codes.
Usage Example:
setUrl(url: string)
setUrl(url: string)
Sets the URL where the error occurred and validates its format.
Usage Example:
setHttpMethod(httpMethod: string)
setHttpMethod(httpMethod: string)
Sets the HTTP method used in the request and validates it against known methods.
Usage Example:
setRequestHeaders(headers: { [key: string]: any })
setRequestHeaders(headers: { [key: string]: any })
Sets the request headers.
Usage Example:
setResponseHeaders(headers: { [key: string]: any })
setResponseHeaders(headers: { [key: string]: any })
Sets the response headers.
Usage Example:
setQueryParams(params: { [key: string]: any })
setQueryParams(params: { [key: string]: any })
Sets the query parameters.
Usage Example:
setRequestBody(body: any)
setRequestBody(body: any)
Sets the body of the HTTP request.
Usage Example:
setResponseBody(body: any)
setResponseBody(body: any)
Sets the body of the HTTP response.
Usage Example:
setClientIp(ip: string)
setClientIp(ip: string)
Sets the client's IP address.
Usage Example:
setLatency(latency: number)
setLatency(latency: number)
Sets the latency of the request in milliseconds.
Usage Example: