dchisel library Null safety

Classes

Audience
Audience claim. Can contains one or more audience entry, used like a list
Cascade
A helper that calls several handlers in sequence and returns the first acceptable response.
DChisel
DChiselDB
DRoute
ECPrivateKey
For ECDSA algorithm, in sign method
ECPublicKey
For ECDSA algorithm, in verify method
EdDSAPrivateKey
For EdDSA algorithm, in sign method
EdDSAPublicKey
For EdDSA algorithm, in verify method
JWT
JWTAlgorithm
JWTKey
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.
RequestBodyAccessor
Reference class for different request body accessors. Provides basic accessors like asString or asJson.
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.
RouterPlus
Extended request router based on shelf Router
RSAPrivateKey
For RSA algorithm, in sign method
RSAPublicKey
For RSA algorithm, in verify method
SecretKey
For HMAC algorithms
Server
An adapter with a concrete URL.
ServerHandler
A connected pair of a Server and a Handler.
ShelfRunContext
WebSocketSession
Abstraction of a websocket lifecycle

Extensions

MiddlewareExtension
MiddlewareExtensions
Extensions on Middleware to aid in composing Middleware and Handlers.
RequestBodyAccessorExtension
ResponseHandlerToMiddleware
RouterParams
RouterPlusExtension
ShelfRequestExtension

Properties

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

Functions

addResponseHandler(List<ResponseHandler> handler) Middleware
cascade(List<Handler> handler) Handler
Merges multiple Handler into a cascade of handler. Uses the shelf Cascade ruleset.
checkAuth() 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.
decodeBase64(String img64, String imageType) File
download({String? filename}) Middleware
Changes the response headers in a way, browsers will handle the http response as a download.
encodeMap(Map<String, dynamic> map) Map<String, dynamic>
generateJwt(String subject, String issuer, String secret, {required String salt}) String
generateSalt([int length = 32]) String
getRandString(int len) String
handleAuth(String secret) Middleware
hashPassword(String password, String salt) String
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.
@Deprecated('Use Request.params instead')
parseECPrivateKeyPEM(String pem) ECPrivateKey?
Parse ECDSA private key from pem string
parseECPublicKeyPEM(String pem) ECPublicKey?
Parse ECDSA public key from pem string
parseRSAPrivateKeyPEM(String pem) RSAPrivateKey?
Parse RSA private key from pem string
parseRSAPublicKeyPEM(String pem) RSAPublicKey?
Parse RSA public key from pem string
resForbidden(String message) Response
resOk(dynamic data) Response
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}) 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.
verifyJwt(String token, String secret) → dynamic
withHotreload(FutureOr<HttpServer> serverFactory(), {FutureOr<void> onReloaded()?, FutureOr<void> onHotReloadAvailable()?, FutureOr<void> onHotReloadNotAvailable()?, FutureOr<void> onHotReloadLog(LogRecord log)?, Level logLevel = logging.Level.OFF}) → void
Provides hot-reloading ability to code that providers an http server.

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.
OnStarted = void Function(Object address, int port)
ResponseHandler = FutureOr<Object?> Function(Request request, dynamic data)
Model for converting an object into another one.

Exceptions / Errors

HijackException
An exception used to indicate that a request has been hijacked.
JWTError
JWTError objects thrown in the case of a jwt sign or verify failure.
JWTExpiredError
An error thrown when jwt is expired
JWTInvalidError
An error thrown when jwt is invalid
JWTNotActiveError
An error thrown when jwt is not active
JWTParseError
An error thrown when parsing failed
JWTUndefinedError
An error thrown by default