Skip to content

Commit

Permalink
Add WebSocket context usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sdogruyol committed Feb 10, 2019
1 parent 1d3f4c7 commit 03fd1ae
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,16 @@ ws "/" do |socket|
end
```

`ws` yields a second parameter which lets you access the `HTTP::Server::Context` which lets you use the underlying `request` and `response`.

```ruby
ws "/" do |socket, context|
headers = context.request.headers

socket.send headers["Content-Type"]?
end
```

# [Testing](#testing)

You can test your Kemal application using [spec-kemal](https://github.com/kemalcr/spec-kemal).
Expand Down

0 comments on commit 03fd1ae

Please sign in to comment.