/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/

use rocket::{
    http::Header,
    response::{self, Responder},
    Request,
};

pub struct Cors<T>(pub T);
impl<'r, T: Responder<'r, 'static>> Responder<'r, 'static> for Cors<T> {
    fn respond_to(self, request: &'r Request<'_>) -> response::Result<'static> {
        let mut r = self.0.respond_to(request)?;
        r.adjoin_header(Header::new("access-controll-allow-origin", "*"));
        Ok(r)
    }
}
