Example #1
0
    def resolve_argument(
        self,
        argument: ComponentMethodArgument,
        request: Request,
        response_headers: MutableMapping[str, str],
    ):
        resolver_match = self._url_resolver.resolve(request.path_info)
        callback, callback_args, callback_kwargs = resolver_match

        if argument.name not in callback_kwargs:
            raise ArgumentNotSupported(argument)

        return argument.type_(callback_kwargs[argument.name])
Example #2
0
 def resolve_argument(
     self,
     argument: ComponentMethodArgument,
     request: Request,
     response_headers: MutableMapping[str, str],
 ):
     annotations = argument.method.annotations.get(ResponseHeaderAnnotation)
     annotation = [
         annotation for annotation in annotations
         if annotation.argument_name == argument.name
     ][0]
     header_name = annotation.header_name
     header = argument.type_(response_headers, header_name)
     return header