ds_shelf library

Classes

Cascade
A helper that calls several handlers in sequence and returns the first acceptable response.
DL
DS
DSshelf2
DSShelfCore
DSStaticFileHanlder
DSUtilitiesBase
Pipeline
A helper that makes it easy to compose a set of Middleware and a Handler.
Request
An HTTP request to be processed by a Shelf application.
Response
The response returned by a Handler.
Route
Annotation for handler methods that requests should be routed when using package shelf_router_generator.
Router
A shelf Router routes requests to handlers based on HTTP verb and route pattern.
Server
An adapter with a concrete URL.
ServerHandler
A connected pair of a Server and a Handler.
ShelfTestHandler
A Handler that handles requests as specified by expect and expectAnything.
ShelfTestServer
A shorthand for creating an HTTP server serving a ShelfTestHandler.
StringUtilities

Extensions

MiddlewareExtensions on Middleware
Extensions on Middleware to aid in composing Middleware and Handlers.
RouterParams on Request
StaticFileHandler on Router

Properties

addChunkedEncoding Middleware
Middleware that adds chunked transfer coding to a responses if none of the following conditions are true:
final

Functions

configureApi(Router router) → void
corsHeaders({Map<String, String>? headers}) Middleware
createFileHandler(String path, {String? url, String? contentType}) Handler
Creates a shelf Handler that serves the file at path.
createMiddleware({FutureOr<Response?> requestHandler(Request)?, FutureOr<Response> responseHandler(Response)?, FutureOr<Response> errorHandler(Object error, StackTrace)?}) Middleware
Creates a Middleware using the provided functions.
createStaticHandler(String fileSystemPath, {bool serveFilesOutsidePath = false, String? defaultDocument, bool listDirectories = false, bool useHeaderBytesForContentType = false, MimeTypeResolver? contentTypeResolver}) Handler
Creates a Shelf Handler that serves files from the provided fileSystemPath.
errorResponse(String message, {int statusCode = 400}) Response
extractBearerToken(Request request) String?
joinPaths(String base, String path) String
jsonResponse(Map<String, dynamic> body, {int statusCode = 200}) Response
logRequests({void logger(String message, bool isError)?}) Middleware
Middleware which prints the time of the request, the elapsed time for the inner handlers, the response's status code and the request URI.
packagesDirHandler({Map<String, Uri>? packageMap}) Handler
A handler that serves virtual packages/ directories wherever they're requested.
packagesHandler({Map<String, Uri>? packageMap}) Handler
A handler that serves the contents of a virtual packages directory.
params(Request request, String name) String
Get a URL parameter captured by the Router.
parseJson(String jsonStr) Map<String, dynamic>
parseQueryParams(Request request) Map<String, dynamic>
proxyHandler(Object url, {Client? client, String? proxyName}) Handler
A handler that proxies requests to url.
sanitizeForSQL(String input) String
saveUploadedFile(Request request, String targetPath) Future<File>
toJson(Map<String, dynamic> jsonObject) String

Typedefs

Handler = FutureOr<Response> Function(Request request)
A function which handles a Request.
Middleware = Handler Function(Handler innerHandler)
A function which creates a new Handler by wrapping a Handler.

Exceptions / Errors

HijackException
An exception used to indicate that a request has been hijacked.