createCookieVar function

Expression createCookieVar(
  1. BaseParameterAnnotation annotation,
  2. ServerParam param
)

Implementation

Expression createCookieVar(
  BaseParameterAnnotation annotation,
  ServerParam param,
) {
  if (annotation is! ServerCookieAnnotation) {
    throw ArgumentError('Invalid annotation type: ${annotation.runtimeType}');
  }

  final cookieVar = refer(
    'context',
  ).property('request').property('headers').property('cookies');

  return cookieVar.index(literalString(annotation.name ?? param.name));
}