shelf_plus
library
Functions
-
addResponseHandler(List<ResponseHandler> handler)
→ Middleware
-
-
cascade(List<Handler> handler)
→ Handler
-
Merges multiple Handler into a cascade of handler.
Uses the shelf Cascade ruleset.
-
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.
-
download({String? filename})
→ Middleware
-
Changes the response headers in a way, browsers will handle the
http response as a download.
-
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.
-
params(Request request, String name)
→ String
-
Get a URL parameter captured by the Router.
-
resolveResponse(Request request, dynamic result)
→ Future<Response>
-
Resolves a shelf Response from generic
result
based on registered ResponseHandler.
-
setContentType(String mimeType)
→ Middleware
-
Sets the content type header of the response to given
mimeType.
-
shelfRun(FutureOr<Handler> init(), {int defaultBindPort = 8080, Object defaultBindAddress = 'localhost', bool defaultEnableHotReload = true, bool defaultShared = false, SecurityContext? securityContext, OnStarted? onStarted, OnStartFailed? onStartFailed, OnWillClose? onWillClose, OnClosed? onClosed})
→ Future<ShelfRunContext>
-
Mechanism to quickly run a shelf app.
-
typeByExtension(String fileExtension, {String unknownMimeType = 'application/unknown'})
→ Middleware
-
Sets the content type header of the response to a mime-type that
matches the give
fileExtension.
Exceptions / Errors
-
HijackException
-
An exception used to indicate that a request has been hijacked.