This repository has been archived by the owner on Jan 23, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'scheme_rack_apps' of git://github.com/JackDanger/bus-sc…
…heme into web
- Loading branch information
Showing
6 changed files
with
87 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module BusScheme | ||
|
||
define 'defwebapp', primitive {|*args| Web::App.new(*args) } | ||
|
||
module Web | ||
class App | ||
def initialize(path, contents) | ||
raise "defwebapp needs to be called with a Lambda" unless contents.is_a? Lambda | ||
@contents = contents | ||
Resource[path] = self | ||
BusScheme::Web.serve | ||
end | ||
|
||
def call(env) | ||
status, headers, body = *@contents.call(BusScheme.cons(env)) | ||
headers = Hash[*headers] | ||
# TODO: sanitize headers and status code | ||
[status, headers, body] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters