getValue method

dynamic getValue(
  1. RequestContext req
)

Obtains a value for this parameter from a RequestContext.

Implementation

getValue(RequestContext req) {
  if (cookie?.isNotEmpty == true) {
    return req.cookies.firstWhere((c) => c.name == cookie)?.value ??
        defaultValue;
  }
  if (header?.isNotEmpty == true) {
    return req.headers.value(header) ?? defaultValue;
  }
  if (session?.isNotEmpty == true) {
    return req.session[session] ?? defaultValue;
  }
  if (query?.isNotEmpty == true) {
    return req.uri.queryParameters[query] ?? defaultValue;
  }
  return defaultValue;
}