dchisel library
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
- ECDSAAlgorithm
- ECPrivateKey
- For ECDSA algorithm, in sign method
- ECPublicKey
- For ECDSA algorithm, in verify method
- EdDSAAlgorithm
- EdDSAPrivateKey
- For EdDSA algorithm, in sign method
- EdDSAPublicKey
- For EdDSA algorithm, in verify method
- HMACAlgorithm
- 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
- RSAAlgorithm
- 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 on Middleware
- MiddlewareExtensions on Middleware
- Extensions on Middleware to aid in composing Middleware and Handlers.
- RequestBodyAccessorExtension on Request
- ResponseHandlerToMiddleware on ResponseHandler
- RouterParams on Request
- RouterPlusExtension on Router
- ShelfRequestExtension on Request
Properties
- addChunkedEncoding → Middleware
-
Middleware that adds
chunked transfer coding
to a 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.
-
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, 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
. -
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.
-
OnClosed
= FutureOr<
void> Function() - OnStarted = void Function(Object address, int port)
- OnStartFailed = void Function(Object e)
-
The type
e
represents the error or exception that occurred. -
OnWillClose
= FutureOr<
void> Function() -
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.
- JWTException
- JWTException objects thrown in the case of a jwt sign or verify failure.
- JWTExpiredException
- An exception thrown when jwt is expired
- JWTInvalidException
- An exception thrown when jwt is invalid
- JWTNotActiveException
- An exception thrown when jwt is not active
- JWTParseException
- An exception thrown when parsing failed
- JWTUndefinedException
- An exception thrown by default