Skip to content

Commit 39d5226

Browse files
committed
Documentation for how to access handlers programatically.
1 parent 301b6dd commit 39d5226

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ $ rackup
2424

2525
Your application should now be available locally, typically `http://localhost:9292`.
2626

27+
### Server Handler
28+
29+
You can also use `Rackup::Handler` to start a server programmatically:
30+
31+
``` ruby
32+
require 'rackup'
33+
34+
# Use the default server:
35+
handler = Rackup::Handler.default
36+
handler.run(app, **options)
37+
38+
# Use a specific server:
39+
handler = Rackup::Handler.get('puma')
40+
handler.run(app, **options)
41+
```
42+
43+
Do not require specific handlers or assume they will exist/work. Instead, use the `default` method to get the best available handler.
44+
2745
## (Soft) Deprecation
2846

2947
For a long time, `rackup` (the executable and implementation) was part of `rack`, and `webrick` was the default server, included with Ruby. It made it easy to run a Rack application without having to worry about the details of the server - great for documentation and demos.

0 commit comments

Comments
 (0)