method GrpcService.prototype.claims
Since 0.3.0
GrpcService.prototype.claims(request: Request): boolean

Whether this service claims the request's path — that is, whether the path lies inside the configured basePath.

The kernel calls this before GrpcService.handleRequest, which answers 404 for a claimed path with no matching procedure and therefore cannot itself be used to tell "not mine" from "mine, but unknown". Without this guard every unmatched route in the application would be answered by gRPC's plain-text 404 instead of the kernel's JSON one.

A root basePath is the exception, and it is load-bearing: '' contains every path, so a prefix test would claim the entire application. The kernel consults claims before route matching, so that would 404 every ordinary route. At the root this therefore claims only paths it can actually serve, mirroring the asymmetry dispatchRequest already documents — "not a known procedure" and "an ordinary application route" are indistinguishable there, so both fall through.

Inside a non-root base path the prefix IS the claim, so an unknown procedure under /grpc answers gRPC's 404 rather than falling through to the application — the M49 behaviour.

Parameters

request: Request

The native fetch request

Return Type

boolean

true when this service will serve the request

Usage

import { GrpcService } from "grpc-plugin/src/index.ts";