Effect<
{
readonly fileResponse: (
path: string,
options?: ServerResponse.Options.WithContent & {
readonly bytesToRead?: SizeInput | undefined
readonly chunkSize?: SizeInput | undefined
readonly offset?: SizeInput | undefined
}
) => Effect<ServerResponse.HttpServerResponse, PlatformError>
readonly fileWebResponse: (
file: HttpBody.FileLike,
options?: ServerResponse.Options.WithContent & {
readonly bytesToRead?: SizeInput | undefined
readonly chunkSize?: SizeInput | undefined
readonly offset?: SizeInput | undefined
}
) => Effect<ServerResponse.HttpServerResponse>
},
never,
EtagImpl.Generator | FileSystem
>Creates the Node HttpPlatform, serving file responses from Node readable
streams and adding MIME type and content-length headers when needed.
export const const make: Effect<
{
readonly fileResponse: (
path: string,
options?: ServerResponse.Options.WithContent & {
readonly bytesToRead?:
| SizeInput
| undefined
readonly chunkSize?: SizeInput | undefined
readonly offset?: SizeInput | undefined
}
) => Effect<
ServerResponse.HttpServerResponse,
PlatformError
>
readonly fileWebResponse: (
file: HttpBody.FileLike,
options?: ServerResponse.Options.WithContent & {
readonly bytesToRead?:
| SizeInput
| undefined
readonly chunkSize?: SizeInput | undefined
readonly offset?: SizeInput | undefined
}
) => Effect<ServerResponse.HttpServerResponse>
},
never,
EtagImpl.Generator | FileSystem
>
const make: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Creates the Node HttpPlatform, serving file responses from Node readable
streams and adding MIME type and content-length headers when needed.
make = import PlatformPlatform.const make: (impl: {
readonly fileResponse: (
path: string,
status: number,
statusText: string | undefined,
headers: Headers.Headers,
start: number,
end: number | undefined,
contentLength: number
) => Response.HttpServerResponse
readonly fileWebResponse: (
file: Body.HttpBody.FileLike,
status: number,
statusText: string | undefined,
headers: Headers.Headers,
options?: {
readonly bytesToRead?:
| FileSystem.SizeInput
| undefined
readonly chunkSize?:
| FileSystem.SizeInput
| undefined
readonly offset?:
| FileSystem.SizeInput
| undefined
}
) => Response.HttpServerResponse
}) => Effect.Effect<
HttpPlatform["Service"],
never,
Etag.Generator | FileSystem.FileSystem
>
Creates an HttpPlatform service from platform-specific file response constructors, using FileSystem and Etag.Generator.
make({
fileResponse: (
path: string,
status: number,
statusText: string | undefined,
headers: Headers.Headers,
start: number,
end: number | undefined,
contentLength: number
) => ServerResponse.HttpServerResponse
fileResponse(path: stringpath, status: numberstatus, statusText: string | undefinedstatusText, headers: Headers.Headersheaders, start: numberstart, end: number | undefinedend, contentLength: numbercontentLength) {
const const stream: anystream = contentLength: numbercontentLength === 0
? import ReadableReadable.from([])
: import FsFs.createReadStream(path: stringpath, { start: numberstart, end: number | undefinedend: end: number | undefinedend === var undefinedundefined ? var undefinedundefined : end: numberend - 1 })
return import ServerResponseServerResponse.const raw: (
body: unknown,
options?: ServerResponse.Options | undefined
) => ServerResponse.HttpServerResponse
Creates a response with a raw body value.
When to use
Use when you want to pass through a body value already understood by the
underlying runtime, such as a Web Response, Blob, or ReadableStream,
for later platform conversion.
raw(const stream: anystream, {
Options.headers?: Headers.Input | undefined(property) Options.headers?: {
content-type: string;
content-length: string;
}
headers: {
...headers: Headers.Headersheaders,
"content-type": headers: Headers.Headersheaders["content-type"] ?? import MimeMime.getType(path: stringpath) ?? "application/octet-stream",
"content-length": contentLength: numbercontentLength.Number.toString(radix?: number): stringReturns a string representation of an object.
toString()
},
Options.status?: number | undefinedstatus,
Options.statusText?: string | undefinedstatusText
})
},
fileWebResponse: (
file: HttpBody.FileLike,
status: number,
statusText: string | undefined,
headers: Headers.Headers,
options?: {
readonly bytesToRead?: SizeInput | undefined
readonly chunkSize?: SizeInput | undefined
readonly offset?: SizeInput | undefined
}
) => ServerResponse.HttpServerResponse
fileWebResponse(file: HttpBody.FileLike(parameter) file: {
name: string;
lastModified: number;
size: number;
stream: () => unknown;
type: string;
}
file, status: numberstatus, statusText: string | undefinedstatusText, headers: Headers.Headersheaders, _options: | {
readonly bytesToRead?: SizeInput | undefined
readonly chunkSize?: SizeInput | undefined
readonly offset?: SizeInput | undefined
}
| undefined
_options) {
return import ServerResponseServerResponse.const raw: (
body: unknown,
options?: ServerResponse.Options | undefined
) => ServerResponse.HttpServerResponse
Creates a response with a raw body value.
When to use
Use when you want to pass through a body value already understood by the
underlying runtime, such as a Web Response, Blob, or ReadableStream,
for later platform conversion.
raw(import ReadableReadable.fromWeb(file: HttpBody.FileLike(parameter) file: {
name: string;
lastModified: number;
size: number;
stream: () => unknown;
type: string;
}
file.HttpBody.FileLike.stream: () => unknownstream() as any), {
Options.headers?: Headers.Input | undefinedheaders: import HeadersHeaders.const merge: (self: Headers.Headers, headers: Headers.Headers) => Headers.Headers (+1 overload)Returns a new Headers collection containing headers from both collections.
Details
Headers from the second collection override headers from the first collection with the same name.
merge(
headers: Headers.Headersheaders,
import HeadersHeaders.const fromRecordUnsafe: (
input: Record.ReadonlyRecord<string, string>
) => Headers
Treats an existing record as Headers unsafely.
Gotchas
This mutates the record's prototype and does not normalize header names; callers must provide the expected lowercase keys.
fromRecordUnsafe({
"content-type": headers: Headers.Headersheaders["content-type"] ?? import MimeMime.getType(file: HttpBody.FileLike(parameter) file: {
name: string;
lastModified: number;
size: number;
stream: () => unknown;
type: string;
}
file.HttpBody.FileLike.name: stringname) ?? "application/octet-stream",
"content-length": file: HttpBody.FileLike(parameter) file: {
name: string;
lastModified: number;
size: number;
stream: () => unknown;
type: string;
}
file.HttpBody.FileLike.size: numbersize.Number.toString(radix?: number): stringReturns a string representation of an object.
toString()
})
),
Options.status?: number | undefinedstatus,
Options.statusText?: string | undefinedstatusText
})
}
})