import { Adaptor } from "../adaptor/mod.ts" ; import { Endpoint } from "./endpoint.ts" ; export interface EndpointConfig { see EndpointInput . pathParameters expectedPath : string ; /**
     * A callback function called by EnlaceServer gives Endpoint the ability to
     * dynamically select an adapter。
     */ selectAdaptor : ( adaptor : Adaptor ) => boolean ; } export type EndpointWithConfigure = { configure : EndpointConfig ; endpoint : Endpoint ; } ; export function isEndpointConfig ( obj ) { return typeof obj === "object" && "expectedPath" in obj && "selectAdaptor" in obj ; } export function combineEndpointConfigure ( lhs , rhs ) { if ( lhs . expectedPath . endsWith ( '/' ) ) { lhs . expectedPath = lhs . expectedPath . slice ( 0 , lhs . expectedPath . length - 1 ) ; } const expectedPath = lhs . expectedPath + rhs . expectedPath ; const selectAdaptor = rhs . selectAdaptor ; return { expectedPath , selectAdaptor } ; }