createHeaderVar function
Expression
createHeaderVar(
)
Implementation
Expression createHeaderVar(
BaseParameterAnnotation annotation,
ServerParam param,
) {
if (annotation is! ServerHeaderAnnotation) {
throw ArgumentError('Invalid annotation type: ${annotation.runtimeType}');
}
var headersRef = refer('context').property('request').property('headers');
if (annotation.all) {
headersRef = headersRef.property('getAll');
} else {
headersRef = headersRef.property('get');
}
return headersRef.call([literalString(annotation.name ?? param.name)]);
}