Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
53 additions
and
42 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,19 @@ | ||
role HTTP::Request::Role { | ||
has Str $.method; | ||
has Str $.uri; | ||
has Str $.version; | ||
has Buf $.data is rw; | ||
has %.params; | ||
has %.headers; | ||
|
||
method header(*@headers) { | ||
my @r; | ||
my %h = @headers.map({ $_.lc => $_ }); | ||
%.headers.keys.map(-> $k { | ||
@r.append($( %h{$k.lc} => %.headers{$k} )) if $k.lc ~~ any %h.keys; | ||
}); | ||
@r | ||
} | ||
} | ||
|
||
# vim: expandtab shiftwidth=4 |
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,14 @@ | ||
use HTTP::Status; | ||
BEGIN my %status := HTTP::Status.Map; | ||
|
||
role HTTP::Response::Role { | ||
has Int:D $.status is rw = 200; | ||
has %.headers is rw; | ||
has $.connection; | ||
has %.statuscodes = %status; | ||
|
||
method close($data?, :$force? = False) {*} | ||
method write($data) {*} | ||
} | ||
|
||
# vim: expandtab shiftwidth=4 |
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,8 @@ | ||
role HTTP::Server::Role { | ||
method handler(Callable $sub) {*} # to be called when request is complete | ||
method middleware(Callable $sub) {*} # to be called when headers are complete | ||
method after(Callable $sub) {*} # to be called when response is complete | ||
method listen() {*} # to be called to start the server | ||
} | ||
|
||
# vim: expandtab shiftwidth=4 |