2023-05-20 13:13:46 +00:00
|
|
|
// Copyright (C) 2023-2099 The crate authors.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Affero General Public License as published by the
|
|
|
|
// Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
// option) any later version.
|
|
|
|
//
|
|
|
|
// This program 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 Affero General Public License
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#![feature(let_chains)]
|
|
|
|
|
2023-05-20 14:27:34 +00:00
|
|
|
mod error;
|
2023-05-20 17:33:33 +00:00
|
|
|
mod web;
|
2023-05-20 14:27:34 +00:00
|
|
|
|
2023-05-20 17:33:33 +00:00
|
|
|
use crate::web::webhooks;
|
2023-05-20 14:27:34 +00:00
|
|
|
|
2023-05-20 13:13:46 +00:00
|
|
|
use std::convert::Infallible;
|
|
|
|
use std::net::SocketAddr;
|
|
|
|
|
|
|
|
use hyper::{
|
|
|
|
service::{make_service_fn, service_fn},
|
2023-05-20 17:33:33 +00:00
|
|
|
Server,
|
2023-05-20 13:13:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
|
|
|
pretty_env_logger::init();
|
|
|
|
|
|
|
|
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
|
2023-05-20 17:33:33 +00:00
|
|
|
let make_svc = make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(webhooks)) });
|
2023-05-20 13:13:46 +00:00
|
|
|
let server = Server::bind(&addr).serve(make_svc);
|
|
|
|
println!("Listening on http://{}", addr);
|
|
|
|
|
|
|
|
if let Err(e) = server.await {
|
|
|
|
eprintln!("Server error: {e}");
|
|
|
|
}
|
|
|
|
}
|