Skip to content

Commit

Permalink
Documentation for how to access handlers programatically.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 20, 2024
1 parent 301b6dd commit 39d5226
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ $ rackup

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

### Server Handler

You can also use `Rackup::Handler` to start a server programmatically:

``` ruby
require 'rackup'

# Use the default server:
handler = Rackup::Handler.default
handler.run(app, **options)

# Use a specific server:
handler = Rackup::Handler.get('puma')
handler.run(app, **options)
```

Do not require specific handlers or assume they will exist/work. Instead, use the `default` method to get the best available handler.

## (Soft) Deprecation

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.
Expand Down

0 comments on commit 39d5226

Please sign in to comment.