{"id":21408613,"url":"https://github.com/raku-community-modules/http-roles","last_synced_at":"2025-06-17T19:09:24.837Z","repository":{"id":32754704,"uuid":"36345756","full_name":"raku-community-modules/HTTP-Roles","owner":"raku-community-modules","description":"Roles for an HTTP::Server with interchangeable backends","archived":false,"fork":false,"pushed_at":"2023-12-07T11:10:34.000Z","size":31,"stargazers_count":3,"open_issues_count":2,"forks_count":4,"subscribers_count":145,"default_branch":"main","last_synced_at":"2024-04-14T14:34:42.655Z","etag":null,"topics":["http","raku","roles"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"dbohdan/automatic-api","license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raku-community-modules.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-27T05:43:39.000Z","updated_at":"2022-05-29T12:22:41.000Z","dependencies_parsed_at":"2022-09-07T07:11:47.725Z","dependency_job_id":null,"html_url":"https://github.com/raku-community-modules/HTTP-Roles","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-Roles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-Roles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-Roles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-Roles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raku-community-modules","download_url":"https://codeload.github.com/raku-community-modules/HTTP-Roles/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225934413,"owners_count":17547740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","raku","roles"],"created_at":"2024-11-22T17:17:28.331Z","updated_at":"2024-11-22T17:17:29.002Z","avatar_url":"https://github.com/raku-community-modules.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/raku-community-modules/HTTP-Roles/actions/workflows/test.yml/badge.svg)](https://github.com/raku-community-modules/HTTP-Roles/actions)\n\nNAME\n====\n\nHTTP::Roles - Roles for an HTTP::Server with interchangeable backends\n\nSYNOPSIS\n========\n\n```raku\nuse HTTP::Roles;\n\nmy class HTTP::Server::MyWay does HTTP::Server::Role {\n    ...\n}\nmy class HTTP::Request::MyWay does HTTP::Request::Role {\n    ...\n}\nmy class HTTP::Response::MyWay does HTTP::Response::Role {\n    ...\n}\n```\n\nDESCRIPTION\n===========\n\nHTTP::Roles provides a set of roles to define the functionality of an HTTP server, and handling requests and responses.\n\nROLES\n=====\n\nHTTP::Server::Role\n------------------\n\nAll of the methods defined by the `HTTP::Server::Role` take a `Callable` as the argument, which should provide the necessary functionality.\n\n### listen\n\nCalling the `listen` method is telling the server to start up and start accepting connections.\n\n### middleware\n\nThe `middleware` method should be called with a `Callable` during server setup: the specified `Callable` is to be executed whenever the reception of the request headers of a request is complete.\n\n### handler\n\nThe `handler` method should be called with a `Callable` during server setup: the specified `Callable` is to be executed whenever the reception of the request headers **and** the body of a request is complete.\n\n### after\n\nThe `after` method should be called with a `Callable` during server setup: the specified `Callable` is to be executed whenever the response is complete and sent.\n\nHTTP::Request::Role\n-------------------\n\nThe `HTTP::Request::Role` provides some generic attributes for the class that *should* be present in any decent `HTTP::Request` class. These are:\n\n```raku\nhas Str $.method;\nhas Str $.uri;\nhas Str $.version;\nhas Buf $.data is rw;\nhas     %.params;\nhas     %.headers;\n```\n\n### header\n\nA generic `header` method to retrieve headers in a case insensitive way from the `%.headers` attribute.\n\nHTTP::Response::Role\n--------------------\n\nThe `HTTP::Response::Role` provides some generic attributes for the class that *should* be present in any decent `HTTP::Response` class.\n\n```raku\nhas Int:D $.status is rw = 200;\nhas       %.headers is rw;\nhas       $.connection;\nhas       %.statuscodes = HTTP::Status.Map;\n```\n\n### write\n\nThe `write` method is expected to write the given data of the response.\n\n### close\n\nThe `close` method is expected to close the connection to the client, taking any optional data to be sent, and a named argument `:force` to forcefully close the connection (which defaults to `False`).\n\nAUTHOR\n======\n\nTony O'Dell\n\nCOPYRIGHT AND LICENSE\n=====================\n\nCopyright 2015 - 2019 Tony O'Dell\n\nCopyright 2020 - 2022 Raku Community\n\nThis library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Fhttp-roles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraku-community-modules%2Fhttp-roles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Fhttp-roles/lists"}