5
1
Derivar 0
A crate to help you fetch and serve WebFinger resources
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
KitaitiMakoto 51b49e8629 Merge pull request 'Specify async-trait version' (#13) from specify-async-trait-version into main
Reviewed-on: #13
há 2 anos
src Remove unnecessary mut há 2 anos
.gitattributes add git attributes and remove executable bit from files in repo há 4 anos
.gitignore Add support for group: and custom prefixes (fixes #3) há 5 anos
.travis.yml add async tests to travis test script há 4 anos
Cargo.toml Specify async-trait version há 2 anos
LICENSE add git attributes and remove executable bit from files in repo há 4 anos
README.md add git attributes and remove executable bit from files in repo há 4 anos
coverage.sh Try to add codecov há 5 anos

README.md

WebFinger Crates.io Libraries.io dependency status for GitHub repo Codecov Build Status

A crate to help you fetch and serve WebFinger resources.

Examples

Fetching a resource:

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:

use webfinger::Resolver;

pub struct MyResolver;

impl Resolver<DatabaseConnection> for MyResolver {
    fn instance_domain<'a>() -> &'a str {
        "instance.tld"
    }

    fn find(acct: String, db: DatabaseConnection) -> Result<Webfinger, ResolverError> {
        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
}