(self: HttpIncomingMessage<E>, that: object)
| 101 | * @since 1.0.0 |
| 102 | */ |
| 103 | export const inspect = <E>(self: HttpIncomingMessage<E>, that: object): object => { |
| 104 | const contentType = self.headers["content-type"] ?? "" |
| 105 | let body: unknown |
| 106 | if (contentType.includes("application/json")) { |
| 107 | try { |
| 108 | body = Effect.runSync(self.json) |
| 109 | } catch { |
| 110 | // |
| 111 | } |
| 112 | } else if (contentType.includes("text/") || contentType.includes("urlencoded")) { |
| 113 | try { |
| 114 | body = Effect.runSync(self.text) |
| 115 | } catch { |
| 116 | // |
| 117 | } |
| 118 | } |
| 119 | const obj: any = { |
| 120 | ...that, |
| 121 | headers: Inspectable.redact(self.headers), |
| 122 | remoteAddress: self.remoteAddress.toJSON() |
| 123 | } |
| 124 | if (body !== undefined) { |
| 125 | obj.body = body |
| 126 | } |
| 127 | return obj |
| 128 | } |
no test coverage detected
searching dependent graphs…