x/oak/middleware/proxy.ts

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Very Popular
Go to Latest
interface ProxyOptions
import { type ProxyOptions } from "https://dotland-vbqsvsrpfncg.deno-staging.dev/x/oak@v11.1.0/middleware/proxy.ts?s=ProxyOptions";

Type Parameters

R extends string[src]
optional
P extends RouteParams<R> = RouteParams<R>
[src]
optional
S extends State = Record<string, any>
[src]

Properties

optional
fetch: Fetch
[src]

The fetch function to use to proxy the request. This defaults to the global fetch function. This is designed for test mocking purposes.

optional
headers: HeadersInit | ProxyHeadersFunction<S> | ProxyRouterHeadersFunction<R, P, S>
[src]

Additional headers that should be set in the response. The value can be a headers init value or a function that returns or resolves with a headers init value.

optional
map: Record<string, R> | ProxyMapFunction<R, P>
[src]

Either a record or a proxy map function that will allow proxied requests being handled by the middleware to be remapped to a different remote path.

optional
match: string | RegExp | ProxyMatchFunction<R, P, S>
[src]

A string, regular expression or proxy match function what determines if the proxy middleware should proxy the request.

If the value is a string the match will be true if the requests pathname starts with the string. In the case of a regular expression, if the pathname

optional
proxyHeaders: boolean
[src]

A flag that indicates if traditional proxy headers should be set in the response. This defaults to true.

Methods

optional
contentType(url: string, contentType?: string): Promise<string | undefined> | string | undefined
[src]

A callback hook that is called after the response is received which allows the response content type to be adjusted. This is for situations where the content type provided by the proxy server might not be suitable for responding with.

optional
request(req: Request): Request | Promise<Request>
[src]

A callback hook which will be called before each proxied fetch request to allow the native Request to be modified or replaced.

optional
response(res: Response): Response | Promise<Response>
[src]

A callback hook which will be called after each proxied fetch response is received to allow the native Response to be modified or replaced.