{"id":13875888,"url":"https://github.com/softprops/afterparty","last_synced_at":"2025-03-16T18:31:35.345Z","repository":{"id":34751575,"uuid":"38732269","full_name":"softprops/afterparty","owner":"softprops","description":"rust github webhook server","archived":false,"fork":false,"pushed_at":"2017-09-03T16:20:04.000Z","size":12726,"stargazers_count":56,"open_issues_count":8,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T19:51:02.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softprops.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-07-08T04:41:24.000Z","updated_at":"2025-02-07T10:34:21.000Z","dependencies_parsed_at":"2022-08-03T22:30:26.926Z","dependency_job_id":null,"html_url":"https://github.com/softprops/afterparty","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fafterparty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fafterparty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fafterparty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fafterparty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softprops","download_url":"https://codeload.github.com/softprops/afterparty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826788,"owners_count":20354220,"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":[],"created_at":"2024-08-06T06:00:48.981Z","updated_at":"2025-03-16T18:31:34.247Z","avatar_url":"https://github.com/softprops.png","language":"Rust","funding_links":[],"categories":["Rust","others"],"sub_categories":[],"readme":"# afterparty\n\n[![Build Status](https://travis-ci.org/softprops/afterparty.svg?branch=master)](https://travis-ci.org/softprops/afterparty) [![Coverage Status](https://coveralls.io/repos/github/softprops/afterparty/badge.svg?branch=master)](https://coveralls.io/github/softprops/afterparty?branch=master) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) [![crates.io](http://meritbadge.herokuapp.com/afterparty)](https://crates.io/crates/afterparty)\n\n\u003e Where your commits go after github\n\nAfterparty is a library for building Github webhook integrations in Rust.\n\n## docs\n\nFind them [here](http://softprops.github.io/afterparty)\n\n## install\n\nAdd the following to your `Cargo.toml` file\n\n```toml\n[dependencies]\nafterparty = \"0.1\"\n```\n\n## usage\n\nAfterparty has two key abstractions, a `Hook`: a handler interface webhook deliveries, and a `Hub`: a registry for hooks. A `Hub` provides `Delivery` instances to interested hooks.\n\nA `Delivery` encodes all relevant webhook request information including a unique identifier for the delivery, the event name, and statically typed payload represented as an enumerated type of `Event`.\n\nHooks subscribe to [Events](https://developer.github.com/webhooks/#events) via `Hub`'s a `handle` and `handle_authenticated` functions.\nTo subscribe to multiple events, subscribe with \"*\" and pattern match on the provided delivery's payload value.\n\nTo register your webhook with Github visit your repo's hooks configuration form `https://github.com/{login}/{repo}/settings/hooks/new` and select the events you\nwant Github to notify your server about.\n\nHubs implements [Hyper](https://github.com/hyperium/hyper)'s Server Handler trait so that it may be mounted into any hyper Server.\n\n```rust\nextern crate afterparty;\nextern crate hyper;\n\nuse hyper::Server;\nuse afterparty::{Delivery, Event, Hub};\n\nfn main() {\n    let mut hub = Hub::new();\n    hub.handle(\"*\", |delivery: \u0026Delivery| {\n        println!(\"rec delivery {:#?}\", delivery)\n    });\n    hub.handle_authenticated(\"pull_request\", \"secret\", |delivery: \u0026Delivery| {\n       println!(\"rec authenticated delivery\");\n       match delivery.payload {\n           Event::PullRequest { ref action, ref sender, .. } =\u003e {\n               println!(\"sender {} action {}\", sender.login, action)\n           },\n           _ =\u003e ()\n       }\n    });\n    let svc = Server::http(\"0.0.0.0:4567\")\n       .unwrap()\n       .handle(hub);\n    println!(\"hub is up\");\n    svc.unwrap();\n}\n```\n\n### note on UFCS\n\nIn the case that you have hyper::server::Handler and hubcaps::Hub in scope you may need to use UFCS to invoke\nthe handle method on a HUB instance.\n\nFor example...\n\n```rust\nextern crate afterparty;\nextern crate hyper;\n\nuse hyper::server::Handle;\nuse afterparty::{Delivery, Hub};\n\nfn main() {\n    let mut hub = Hub::new();\n    hubcaps::Hub::handle(\u0026mut hub, \"*\", |delivery: \u0026Delivery| { });\n}\n```\n\n## building\n\nAs far as rust project builds go this one is somewhat interesting. This library uses serde for json encoding/decoding\nand is focused on stable rust releases so a tactic for code generatation at build time is employed. Before that happens\nan attempt is made to synthesize structs based on Github api documentation json vendored in the data directory.\nA known issue exists where the repo `deployments_url` field is omitted with a fresh set of json. serde will error at\ndeserializing because of this. This field was hand added within the json vendored dataset for the time being. Serde 0.7\nwill likely be released soon and will enable this library to avoid these kinds of runtime deserialization errors for\nmissing fields.\n\nDoug Tangren (softprops) 2015-2016\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fafterparty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftprops%2Fafterparty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fafterparty/lists"}