网页
综合
更新时间 2026-11-14 09:26:37
index - @rabbit-company/web - JSR
自动蜘蛛
jsr.io
正文约 4276 字
High-performance web framework
High-performance web framework with trie-based routing, middleware support, and extensive caching.
Adds middleware using the specified pattern and returns an ID for later removal. This is an alternative to use() that returns an ID instead of the Web instance.
Adds a route with the specified method, path, and handlers to the trie structure.
Removes all routes and middleware, effectively resetting the application.
Registers a DELETE route handler.
Registers a GET route handler.
Gets all registered middleware with their IDs and metadata.
Gets all registered routes with their IDs and metadata.
Main request handler that processes incoming requests through the middleware chain and route handlers. This method implements several optimization paths for different scenarios:
Request handler optimized for Bun runtime with automatic IP extraction. Uses Bun's server request info for reliable client IP detection. For WebSocket upgrades, runs middleware (like ipExtract) before upgrading to ensure the real client IP is available via ws.data.clientIp.
Request handler optimized for Cloudflare Workers or Pages Functions. Automatically extracts the client IP from the "CF-Connecting-IP" header.
Request handler optimized for Deno runtime with automatic IP extraction. Uses Deno's ServeHandlerInfo for reliable client IP detection.
Request handler for Node.js that handles both request and response. Automatically converts between Node.js and Web APIs and extracts client IP.
Registers a HEAD route handler. HEAD responses automatically strip the response body while preserving headers and status.
Starts a server with automatic runtime detection. Automatically selects the appropriate server implementation based on the runtime environment.
Matches a method and path against the trie structure to find handlers and extract parameters.
Sets a global error handler for the application. This handler will be called whenever an unhandled error occurs during request processing.
Sets a custom 404 Not Found handler for the application. This handler will be called whenever a request doesn't match any registered routes.
Registers an OPTIONS route handler for CORS preflight requests. OPTIONS requests are typically used to determine what HTTP methods are supported for a given endpoint.
Registers a PATCH route handler for partial updates to resources. PATCH is typically used when you want to update only specific fields of a resource.
Registers a POST route handler.
Registers a PUT route handler for complete resource updates. PUT is typically used when you want to replace an entire resource.
Removes middleware by its ID.
Removes all middleware matching the given criteria.
Removes a route by its ID.
Removes all routes matching the given criteria.
Mounts a sub-application at the specified path prefix. All routes from the sub-application will be prefixed with the given path.
Creates a scoped sub-application that inherits middleware and routes with a path prefix. Useful for organizing routes and creating modular applications.
Registers middleware that will run for matching requests. Middleware can be global, path-specific, or method and path specific.
Sets up WebSocket handlers for Bun runtime. This method must be called before starting the server with listen().
A file reference returned by Bun.file().
Whether the file exists on disk
Bun specific server options.
Serve HTTP/1.1. Set to false together with http2 and/or http3 to refuse HTTP/1.x clients (they receive 505 HTTP Version Not Supported). This also disables WebSockets.
Also serve HTTP/2 on the same port (experimental, Bun 1.4+). With tls, clients offering "h2" via ALPN get HTTP/2 and everyone else HTTP/1.1. Without tls, connections that open with the HTTP/2 preface (prior knowledge) get HTTP/2. WebSockets are not supported over HTTP/2 (They keep working over HTTP/1.1).
Also listen for HTTP/3 (QUIC) on UDP of the same port (experimental, Bun 1.4+). Requires tls. Responses advertise it with an Alt-Svc header so browsers upgrade on their own. WebSockets are not supported over HTTP/3 (They keep working over HTTP/1.1).
Maximum allowed request body size in bytes.
Set the SO_REUSEPORT flag so multiple processes can bind to the same port
Server name for the Server header
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。