MCPcopy Create free account
hub / github.com/Effect-TS/effect / ServerRequestImpl

Class ServerRequestImpl

packages/effect/src/http/HttpServerRequest.ts:518–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516}
517
518class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
519 readonly [TypeId]: typeof TypeId
520 readonly [HttpIncomingMessage.TypeId]: typeof HttpIncomingMessage.TypeId
521 readonly source: Request
522 readonly url: string
523 public headersOverride?: Headers.Headers | undefined
524 private remoteAddressOverride?: Option.Option<string> | undefined
525 private peerAddressOverride?: Option.Option<string> | undefined
526 readonly protocol: "http" | "https" | undefined
527
528 constructor(
529 source: Request,
530 url: string,
531 headersOverride?: Headers.Headers,
532 remoteAddressOverride?: Option.Option<string>,
533 peerAddressOverride?: Option.Option<string>,
534 protocol?: "http" | "https"
535 ) {
536 super()
537 this[TypeId] = TypeId
538 this[HttpIncomingMessage.TypeId] = HttpIncomingMessage.TypeId
539 this.source = source
540 this.url = url
541 this.headersOverride = headersOverride
542 this.remoteAddressOverride = remoteAddressOverride
543 this.peerAddressOverride = peerAddressOverride
544 this.protocol = protocol
545 }
546 toJSON(): unknown {
547 return HttpIncomingMessage.inspect(this, {
548 _id: "HttpServerRequest",
549 method: this.method,
550 url: UrlParams.redactUrl(this.originalUrl)
551 })
552 }
553 modify(
554 options: {
555 readonly url?: string | undefined
556 readonly headers?: Headers.Headers | undefined
557 readonly remoteAddress?: Option.Option<string> | undefined
558 readonly peerAddress?: Option.Option<string> | undefined
559 readonly protocol?: "http" | "https" | undefined
560 }
561 ) {
562 return new ServerRequestImpl(
563 this.source,
564 options.url ?? this.url,
565 options.headers ?? this.headersOverride,
566 "remoteAddress" in options ? options.remoteAddress : this.remoteAddressOverride,
567 options.peerAddress ?? this.peerAddressOverride,
568 options.protocol ?? this.protocol
569 )
570 }
571 get method(): string {
572 return this.source.method.toUpperCase()
573 }
574 get originalUrl() {
575 return this.source.url

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected