https://github.com/plume-org/webfinger
A crate to help you fetch and serve WebFinger resources
https://github.com/plume-org/webfinger
decentralization federation rust webfinger
Last synced: 5 months ago
JSON representation
A crate to help you fetch and serve WebFinger resources
- Host: GitHub
- URL: https://github.com/plume-org/webfinger
- Owner: Plume-org
- License: gpl-3.0
- Created: 2018-06-18T21:05:28.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2022-11-13T01:32:22.000Z (almost 3 years ago)
- Last Synced: 2025-05-13T01:08:46.028Z (5 months ago)
- Topics: decentralization, federation, rust, webfinger
- Language: Rust
- Homepage: https://crates.io/crates/webfinger
- Size: 48.8 KB
- Stars: 10
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebFinger    [](https://travis-ci.org/Plume-org/webfinger)
A crate to help you fetch and serve WebFinger resources.
## Examples
Fetching a resource:
```rust
use webfinger::resolve;fn main() {
let res = resolve("acct:test@example.org", true).expect("Error while fetching resource");println!("Places to get more informations about {}:", res.subject);
for link in res.links.into_iter() {
println!("- {}", link.href);
}
}
```Serving resources:
```rust
use webfinger::Resolver;pub struct MyResolver;
impl Resolver for MyResolver {
fn instance_domain<'a>() -> &'a str {
"instance.tld"
}fn find(acct: String, db: DatabaseConnection) -> Result {
if let Some(user) = db.find_user_by_name(acct) {
Ok(Webfinger {
subject: acct.clone(),
aliases: vec![acct.clone()],
links: vec![
Link {
rel: "http://webfinger.net/rel/profile-page".to_string(),
mime_type: None,
href: user.profile_url()
}
]
})
} else {
Err(ResolverError::NotFound)
}
}
}fn main() {
// Start a web server and map /.well-known/webfinger to a function calling MyResolver::endpoint
}
```