| 162 | }) |
| 163 | |
| 164 | return HttpRouter.of({ |
| 165 | [TypeId]: TypeId, |
| 166 | prefixed(this: HttpRouter, prefix: string) { |
| 167 | prefix = removeTrailingSlash(prefix as PathInput) |
| 168 | return HttpRouter.of({ |
| 169 | ...this, |
| 170 | prefixed: (newPrefix: string) => this.prefixed(prefixPath(newPrefix, prefix)), |
| 171 | addAll: (routes) => addAll(routes.map(prefixRoute(prefix))) as any, |
| 172 | add: (method, path, handler, options) => |
| 173 | addAll([ |
| 174 | makeRoute({ |
| 175 | method, |
| 176 | path: prefixPath(path, prefix) as PathInput, |
| 177 | handler: HttpServerResponse.isHttpServerResponse(handler) ? |
| 178 | Effect.succeed(handler) : |
| 179 | Effect.isEffect(handler) |
| 180 | ? handler |
| 181 | : Effect.flatMap(HttpServerRequest.HttpServerRequest, handler), |
| 182 | uninterruptible: options?.uninterruptible ?? false, |
| 183 | prefix |
| 184 | }) |
| 185 | ]) |
| 186 | }) |
| 187 | }, |