title: How can I get headers or a specific header from my backend API?
body: <p>I want to retrieve a specific header from my API inside a function with fastAPI, but I can't found a solution for this.</p>
  <p>In flask was simply: <code>request.headers['your-header-name']</code></p>
  <p>Why the hell with fastAPI is so complicated to do a simple thing like this?</p>
  <p>Anyone know a solution to retrieve a header? Thanks :)</p>
  <p>The decorator:</p>
  <pre><code>def token_required(f):
      @wraps(f)
      def decorator(*args, **kwargs):
          CONFIG = settings.read_config()
          token = None
          headers = Request.headers
          if &quot;Authorization&quot; in headers:
              auth_header = Request.headers
              token = auth_header
          elif not token:
              return {&quot;Error&quot;: &quot;Token is missing or incorrect header name&quot;}, 401
  
          try:
              public_key = CONFIG[&quot;APPLICATION&quot;][&quot;PUBLIC_KEY&quot;]
              claim = jwt.decode(token, public_key)
              claim.validate()
          except UnicodeDecodeError as err:
              return {&quot;Error&quot;: f&quot;An error occurred -&gt; {err} check your token&quot;}, 401
  
          return f(*args, **kwargs)
  
      return decorator
  </code></pre>
  <p>I need to read 'Authorization' header to check if exist or not.</p>