> For the complete documentation index, see [llms.txt](https://iris-go.gitbook.io/iris/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://iris-go.gitbook.io/iris/requests/headers.md).

# Headers

**Content-Type Requested:&#x20;*****\****

```go
// Register the route...
app.Get("/", handler)

func handler(ctx iris.Context) {
    requestID := ctx.GetHeader("X-Request-Id")
    authentication := ctx.GetHeader("Authentication")
}
```

To get all request headers use `ctx.Request().Header` instead.

## Bind

The `Context.ReadHeaders(ptr interface{}) error` is the method which binds request headers to a custom value.

Let's create our Go structure.

```go
type myHeaders struct {
	RequestID      string `header:"X-Request-Id,required"`
	Authentication string `header:"Authentication,required"`
}
```

Now, the handler which reads the request headers and binds them to a "myHeaders" value.

```go
func handler(ctx iris.Context) {
    var hs myHeaders
    if err := ctx.ReadHeaders(&hs); err != nil {
        ctx.StopWithError(iris.StatusInternalServerError, err)
        return
    }

    ctx.JSON(hs)
}
```

**Request**

```sh
curl -H "x-request-id:373713f0-6b4b-42ea-ab9f-e2e04bc38e73" -H "authentication: Bearer my-token" \
http://localhost:8080
```

**Result**

```json
{
  "RequestID": "373713f0-6b4b-42ea-ab9f-e2e04bc38e73",
  "Authentication": "Bearer my-token"
}
```
