Webfinger client & server helpers for actix-web
Go to file
asonix 171e35d656
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Check without default features in drone for all targets
2023-08-17 17:01:29 -05:00
examples Clippy 2021-12-30 12:14:29 -06:00
src Make awc optional 2023-08-17 16:57:49 -05:00
.drone.yml Check without default features in drone for all targets 2023-08-17 17:01:29 -05:00
.gitignore Add nix 2023-06-03 13:09:59 -05:00
Cargo.toml Make awc optional 2023-08-17 16:57:49 -05:00
flake.lock Update flake 2023-08-17 16:57:39 -05:00
flake.nix Add nix 2023-06-03 13:09:59 -05:00
LICENSE Add documentation 2019-01-28 14:16:51 -06:00
README.md Update versions and examples 2022-03-08 11:56:05 -06:00

Actix Webfinger

A library to aid in resolving and providing webfinger objects with the Actix Web web framework.

The main functionality this crate provides is through the Webfinger::fetch method for Actix Web-based clients, and the Resolver<S> trait for Actix Web-based servers.


First, add Actix Webfinger as a dependency

actix-rt = "2.6.0"
actix-web = "4.0.0"
actix-webfinger = "0.4.0"

Then use it in your application

Client Example

use actix_webfinger::Webfinger;
use awc::Client;
use std::error::Error;

async fn main() -> Result<(), Box<dyn Error>> {
    let client = Client::default();
    let wf = Webfinger::fetch(

    println!("asonix's webfinger:\n{:#?}", wf);

Server Example

use actix_web::{middleware::Logger, web::Data, App, HttpServer};
use actix_webfinger::{Resolver, Webfinger};
use std::{error::Error, future::Future, pin::Pin};

#[derive(Clone, Debug)]
pub struct MyState {
    domain: String,

pub struct MyResolver;

type LocalBoxFuture<'a, Output> = Pin<Box<dyn Future<Output = Output> + 'a>>;

impl Resolver for MyResolver {
    type State = Data<MyState>;
    type Error = actix_web::error::JsonPayloadError;

    fn find(
        scheme: Option<&str>,
        account: &str,
        domain: &str,
        state: Data<MyState>,
    ) -> LocalBoxFuture<'static, Result<Option<Webfinger>, Self::Error>> {
        let w = if scheme == Some("acct:") && domain == state.domain {
            Some(Webfinger::new(&format!("{}@{}", account, domain)))
        } else {

        Box::pin(async move { Ok(w) })

async fn main() -> Result<(), Box<dyn Error>> {
    std::env::set_var("RUST_LOG", "info");
    HttpServer::new(|| {
            .app_data(Data::new(MyState {
                domain: "localhost:8000".to_owned(),



Feel free to open issues for anything you find an issue with. Please note that any contributed code will be licensed under the GPLv3.


Copyright © 2020 Riley Trautman

Actix Webfinger is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Actix Webfinger is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of Tokio ZMQ.

You should have received a copy of the GNU General Public License along with Actix Webfinger. If not, see http://www.gnu.org/licenses/.