ruta library
Ruta Framework
Classes
- CorsHeadersMiddleware
-
Converted from
shelf - Endpoint
- Represents an API endpoint in the Ruta framework.
-
Field<
T> - A class representing a data field with validation capabilities.
- FormData
- LogRequestsMiddleware
-
Converted from
shelf - Middleware
- Middleware class that wraps simple middleware function
- Pipeline
- A helper that makes it easy to compose a set of Middleware and a Handler.
- Request
- An HTTP request for the Ruta framework.
- Response
- An HTTP response for the Ruta framework.
- Route
- Abstract class for routes. Every route will inherit from this class
- Router
- A router that routes requests to handlers based on HTTP verb and route pattern.
- RouterEntry
- Represents a route entry in the router.
- UploadedFile
- ValidationResult
- Represents the result of a validation process.
Enums
- HttpMethod
- HTTP Method such as GET or PUT.
Extensions
- GetOrAsync on GetIt
- Extension on GetIt to provide a convenience method for resolving dependencies synchronously with fall-back to asynchronous resolution if the instance is not ready yet.
- HandlerUse on Handler
- Extension on Handler which adds support for applying middleware to the request pipeline.
Properties
- formUrlEncodedContentType → ContentType
-
Content-Type: application/x-www-form-urlencoded
final
- multipartFormDataContentType → ContentType
-
Content-Type: multipart/form-data
final
Functions
-
defaultRutaRun(
Future< Handler> handlerCallback(), InternetAddress address, int port) → Future<HttpServer> - Default function for running server
-
fromShelfHandler(
Handler handler) → Handler -
Convert from a
shelf.Handlerinto a Handler. -
fromShelfMiddleware(
Middleware middleware) → MiddlewareFunc -
Convert from
shelf.Middlewareinto Middleware. -
hotReload(
FutureOr< HttpServer> initializer()) → void -
Hot reload support for the server returned by the
initializer. -
parseFormData(
{required Map< String, String> headers, required Future<String> body(), required Stream<List< bytes()}) → Future<int> >FormData> -
Parses the body as form data and returns a
Future<Map<String, dynamic>>. Throws a StateError if the MIME type is not "application/x-www-form-urlencoded" or "multipart/form-data". https://fetch.spec.whatwg.org/#ref-for-dom-body-formdata%E2%91%A0 -
serve(
Handler handler, Object address, int port, {String? poweredByHeader = 'Dart with package:ruta', SecurityContext? securityContext, }) → Future< HttpServer> - Starts an HTTP server that serves requests using the provided handler.
-
toShelfHandler(
Handler handler) → Handler -
Convert from a Handler into a
shelf.Handler. -
toShelfMiddleware(
MiddlewareFunc middleware) → Middleware -
Convert from Middleware into
shelf.Middleware. -
webSocketHandler(
void onConnection(WebSocketChannel webSocket, String? subprotocol), {Iterable< String> ? protocols, Iterable<String> ? allowedOrigins, Duration? pingInterval}) → Handler -
Creates a WebSocket handler that delegates connections to the provided
onConnectioncallback.
Typedefs
-
Handler
= FutureOr<
Response> Function(Request request) - A function type that represents an HTTP request handler in the Ruta framework.
- MiddlewareFunc = Handler Function(Handler handler)
- A function which creates a new Handler by wrapping a Handler.
-
Validator<
T> = ValidationResult Function(T value) - Defines a type alias named Validator that takes a generic type T It represents a function that:
Exceptions / Errors
- ApiException
- Represents an API exception that can be converted into an HTTP response.