Skip to content

Commit

Permalink
Add cookies example.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 20, 2024
1 parent a1147b8 commit a404a9e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/cookies/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env falcon --verbose serve -c
# frozen_string_literal: true

require 'rack/request'

KEY = 'my cookie'

run do |env|
request = Rack::Request.new(env)
puts "My Cookie: #{request.cookies[KEY]}"
puts "All Cookies: #{request.cookies}"

headers = {}
Rack::Utils.set_cookie_header!(headers, KEY, 'bar')

[200, headers, ["Hello World!"]]
end

0 comments on commit a404a9e

Please sign in to comment.