- @override
Executed prior to handling a request, but after the request
has been set.
This method is used to do pre-process setup and filtering. The request
will be set, but its body will not be decoded
nor will the appropriate responder method be selected yet. By default, returns the request. If this method returns a Response
, this
controller will stop processing the request and immediately return the Response
to the HTTP client.
May not return any other Request
than req
.
Source
@override Future<RequestOrResponse> willProcessRequest(Request req) async { if (req.path.orderedVariableNames.length > 0) { var firstVarName = req.path.orderedVariableNames.first; var idValue = req.path.variables[firstVarName]; if (idValue != null) { var primaryKeyDesc = query.entity.attributes[query.entity.primaryKey]; if (primaryKeyDesc.isAssignableWith(idValue)) { query.where[query.entity.primaryKey] = idValue; } else if (primaryKeyDesc.type == ManagedPropertyType.bigInteger || primaryKeyDesc.type == ManagedPropertyType.integer) { try { query.where[query.entity.primaryKey] = int.parse(idValue); } on FormatException { return new Response.notFound(); } } else { return new Response.notFound(); } } } return super.willProcessRequest(req); }