BloomRequest class

Represents an incoming HTTP request in Bloom API routes, SSR endpoints, and middleware.

Encapsulates the HTTP method, request uri, incoming headers, route params, queryParams, binary rawBody (or streaming body for multipart uploads), and helper accessors for parsing JSON, UTF-8 text, URL-encoded form data, and streaming multipart data.

Example

router.post('/api/users/:orgId', (request) async {
  final orgId = request.params['orgId'];
  final role = request.queryParams['role'] ?? 'member';
  final data = request.json() as Map<String, dynamic>?;
  final authHeader = request.headers['authorization'];

  return BloomResponse.json({
    'orgId': orgId,
    'role': role,
    'name': data?['name'],
    'isSecure': request.isSecure,
  });
});

Constructors

BloomRequest({required String method, required Uri uri, Map<String, String> headers = const {}, Map<String, String>? params, dynamic body, Uint8List? rawBody, Stream<List<int>>? streamBody, int? maxRequestBodyBytes, bool? isSecure})
Creates a BloomRequest instance.

Properties

bodyJson → dynamic
Convenient getter for decoded JSON body payload.
no setter
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
Map of incoming HTTP request headers with lowercase keys.
final
isSecure bool
Whether the request was received over a secure HTTPS connection or behind an SSL proxy.
final
isStreaming bool
Whether this request's body is delivered via an unbuffered stream rather than pre-buffered bytes.
no setter
method String
HTTP method string in uppercase (e.g. 'GET', 'POST', 'PUT', 'DELETE').
final
params Map<String, String>
URL path parameters extracted by the router regex matching (e.g. {'id': '123'}).
final
path String
The path component of the request URI (e.g. '/api/tasks').
no setter
queryParams Map<String, String>
Map of query string parameters decoded from the request URI.
no setter
rawBody Uint8List
Raw binary request payload bytes.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
uri Uri
Full request URI including scheme, host, path, and query parameters.
final

Methods

copyWith({String? method, Uri? uri, Map<String, String>? headers, Map<String, String>? params, Uint8List? rawBody, Stream<List<int>>? streamBody, int? maxRequestBodyBytes, bool? isSecure}) BloomRequest
Creates a copy of this request with the specified fields replaced.
formData() Map<String, String>
Parses the request body as URL-encoded form data (application/x-www-form-urlencoded).
json() → dynamic
Parses the request body as JSON.
multipart({int? maxBytes}) Stream<BloomMultipartPart>
Parses the incoming streaming multipart/form-data request body.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
text() String
Decodes and returns the raw request body as a UTF-8 string.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited