Skip to Content
Drash v3 is in beta. APIs may change.

ResourceProxy

A Resource that forwards every HTTP method to another resource instance.

import { ResourceProxy } from "@drashland/drash/standard/http/ResourceProxy.js";

Nothing in the framework uses this class. It is exported, but no other file in src/ imports it. ResourceGroup generates its own proxy classes inline rather than extending this one. Treat it as available, not as load-bearing.

Properties

PropertyTypeNotes
pathsstring[]Copied from the original in setOriginal().
original_instanceResourceProtected. The resource being forwarded to. Optional.

Methods

setOriginal(originalInstance)

Sets the resource to forward to, and copies its paths onto the proxy so routing still resolves. Returns the instance it was given.

The Nine HTTP Methods

CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, and TRACE each forward to the same method on original_instance:

public GET(request: unknown): unknown { return this.original_instance?.GET(request); }

How It Differs from Middleware

Middleware is the class the framework actually uses to wrap a resource. The two look similar but behave differently:

ResourceProxyMiddleware
Forwards byA fixed method per verbReading input.method at call time
Missing originalOptional chaining — returns undefinedThrows
Copies pathsYes, in setOriginal()No
ALL() hookNoneIntercepts every method

The optional chaining is the part to be careful with: a proxy with no original returns undefined rather than failing, and the chain turns that into a 500 further along.

Last updated on