@effect/platform
Advanced tools
Comparing version 0.16.0 to 0.16.1
@@ -28,2 +28,3 @@ import * as Option from "@effect/data/Option"; | ||
readonly headers: Headers.Headers; | ||
readonly remoteAddress: Option.Option<string>; | ||
readonly json: Effect.Effect<never, E, unknown>; | ||
@@ -30,0 +31,0 @@ readonly text: Effect.Effect<never, E, string>; |
@@ -44,4 +44,7 @@ /** | ||
readonly formDataStream: Stream.Stream<never, FormData.FormDataError, FormData.Part>; | ||
readonly setUrl: (url: string) => ServerRequest; | ||
readonly replaceHeaders: (headers: Headers.Headers) => ServerRequest; | ||
readonly modify: (options: { | ||
readonly url?: string; | ||
readonly headers?: Headers.Headers; | ||
readonly remoteAddress?: string; | ||
}) => ServerRequest; | ||
} | ||
@@ -48,0 +51,0 @@ /** |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.schemaJson = exports.fromWeb = exports.TypeId = void 0; | ||
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option")); | ||
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect")); | ||
@@ -36,2 +37,5 @@ var Headers = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/platform/Http/Headers")); | ||
} | ||
get remoteAddress() { | ||
return Option.none(); | ||
} | ||
get stream() { | ||
@@ -38,0 +42,0 @@ return this.source.body ? Stream.fromReadableStream(() => this.source.body, _ => internalError.responseError({ |
@@ -45,3 +45,6 @@ "use strict"; | ||
exports.b3Response = b3Response; | ||
const xForwardedHeaders = /*#__PURE__*/make(httpApp => Effect.updateService(httpApp, ServerRequest.ServerRequest, request => request.headers["x-forwarded-host"] ? request.replaceHeaders(Headers.set(request.headers, "host", request.headers["x-forwarded-host"])) : request)); | ||
const xForwardedHeaders = /*#__PURE__*/make(httpApp => Effect.updateService(httpApp, ServerRequest.ServerRequest, request => request.headers["x-forwarded-host"] ? request.modify({ | ||
headers: Headers.set(request.headers, "host", request.headers["x-forwarded-host"]), | ||
remoteAddress: request.headers["x-forwarded-for"]?.split(",")[0].trim() | ||
}) : request)); | ||
/** @internal */ | ||
@@ -48,0 +51,0 @@ exports.xForwardedHeaders = xForwardedHeaders; |
@@ -135,3 +135,5 @@ "use strict"; | ||
const prefexLen = prefix.length; | ||
return request.setUrl(request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen)); | ||
return request.modify({ | ||
url: request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen) | ||
}); | ||
} | ||
@@ -138,0 +140,0 @@ class RouteImpl { |
{ | ||
"name": "@effect/platform", | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"description": "Unified interfaces for common platform-specific services", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -37,2 +37,3 @@ /** | ||
readonly headers: Headers.Headers | ||
readonly remoteAddress: Option.Option<string> | ||
readonly json: Effect.Effect<never, E, unknown> | ||
@@ -39,0 +40,0 @@ readonly text: Effect.Effect<never, E, string> |
@@ -52,4 +52,9 @@ /** | ||
readonly setUrl: (url: string) => ServerRequest | ||
readonly replaceHeaders: (headers: Headers.Headers) => ServerRequest | ||
readonly modify: ( | ||
options: { | ||
readonly url?: string | ||
readonly headers?: Headers.Headers | ||
readonly remoteAddress?: string | ||
} | ||
) => ServerRequest | ||
} | ||
@@ -56,0 +61,0 @@ |
@@ -0,1 +1,2 @@ | ||
import * as Option from "@effect/data/Option" | ||
import * as Effect from "@effect/io/Effect" | ||
@@ -42,2 +43,6 @@ import type * as Error from "@effect/platform/Http/ClientError" | ||
get remoteAddress(): Option.Option<string> { | ||
return Option.none() | ||
} | ||
get stream(): Stream.Stream<never, Error.ResponseError, Uint8Array> { | ||
@@ -44,0 +49,0 @@ return this.source.body |
@@ -78,7 +78,10 @@ import { flow } from "@effect/data/Function" | ||
request.headers["x-forwarded-host"] | ||
? request.replaceHeaders(Headers.set( | ||
request.headers, | ||
"host", | ||
request.headers["x-forwarded-host"] | ||
)) | ||
? request.modify({ | ||
headers: Headers.set( | ||
request.headers, | ||
"host", | ||
request.headers["x-forwarded-host"] | ||
), | ||
remoteAddress: request.headers["x-forwarded-for"]?.split(",")[0].trim() | ||
}) | ||
: request) | ||
@@ -85,0 +88,0 @@ ) |
@@ -168,3 +168,3 @@ import * as Chunk from "@effect/data/Chunk" | ||
const prefexLen = prefix.length | ||
return request.setUrl(request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen)) | ||
return request.modify({ url: request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen) }) | ||
} | ||
@@ -171,0 +171,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1063051
18215