add feature to specify default backend

This commit is contained in:
Jun Kurihara 2022-06-28 11:51:38 -04:00
commit 3491b80142
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
9 changed files with 50 additions and 12 deletions

View file

@ -1,9 +1,9 @@
// use super::proxy_handler::handle_request;
use crate::{backend::Backend, error::*, globals::Globals, log::*};
use crate::{backend::Backends, error::*, globals::Globals, log::*};
use hyper::{
client::connect::Connect, server::conn::Http, service::service_fn, Body, Client, Request,
};
use std::{collections::HashMap, net::SocketAddr, sync::Arc};
use std::{net::SocketAddr, sync::Arc};
use tokio::{
io::{AsyncRead, AsyncWrite},
net::TcpListener,
@ -38,8 +38,8 @@ where
T: Connect + Clone + Sync + Send + 'static,
{
pub listening_on: SocketAddr,
pub tls_enabled: bool, // TCP待受がTLSかどうか
pub backends: Arc<HashMap<String, Backend>>, // TODO: hyper::uriで抜いたhostで引っ掛ける。Stringでいいのか
pub tls_enabled: bool, // TCP待受がTLSかどうか
pub backends: Arc<Backends>,
pub forwarder: Arc<Client<T>>,
pub globals: Arc<Globals>,
}