# 在Laravel中读取请求头

如果你获取了一个请求，也可以轻松的读取头。例如13-6所示

{% code title="Example 13-6. Reading a request header in Laravel" %}

```php
Route::get('dogs', function (Request $request) { 
    var_dump($request->header('Accept'));
});
```

{% endcode %}

现在你已经可以读取请求头以及设置响应头，让我们看看如何自定义API


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/bian-xie-apis/du-qu-he-fa-song-headers/zai-laravel-zhong-du-qu-qing-qiu-tou.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
