DEV Community

Cover image for Introducing Humming-Bird v3
Rawley Fowler
Rawley Fowler

Posted on

Introducing Humming-Bird v3

Hey folks! It's been a while!

I've been busy, but I haven't forgotten about Humming-Bird. Actually I've been quite busy trying to figure out Web-Sockets, and swappable back-ends for Humming-Bird, features requested by many!

Web-Sockets have been put on the back-burner for a bit, but swappable back-ends, and many bug-fixes have been completed leading to a new version bump.

A lot has changed, and I'm excited to see what sort of back-ends the community may come up with.

To implement a Humming-Bird back-end, simply write a class that does Humming-Bird::Backend;, and implement the listen routine, with a single argument of a function that takes a Humming-Bird::Glue::Request and returns a Humming-Bird::Glue::Response:

use Humming-Bird::Glue;

unit role Humming-Bird::Backend::MyBackend;

method listen(&handler) {
    my $request  = Humming-Bird::Glue::Request.decode(somehow-get-http-request());
    my $response = &handler($request);
Enter fullscreen mode Exit fullscreen mode

Now in your Humming-Bird app add the following to the listen clause:

use Humming-Bird::Core;

get('/', -> $request, $response {
    $response.html("Hello World!");

Enter fullscreen mode Exit fullscreen mode

Thanks for reading, Raku rocks!

Top comments (1)

raiph profile image

To implement a Humming-Bird back-end, simply write a class that does Humming-Bird::Backend ...:

While I know Raku so can guess what you mean, your example doesn't show any class that does anything, which might confuse newbie Rakoons.