Rename Proxy descr to HttpProxy

main
Brian Picciano 11 months ago
parent b81b59fc0a
commit f7ecafbc17
  1. 4
      .dev-config.yml
  2. 25
      README.md
  3. 2
      src/domain/manager.rs
  4. 2
      src/main.rs
  5. 14
      src/origin/descr.rs
  6. 8
      src/origin/proxy.rs
  7. 2
      src/service/http.rs
  8. 2
      src/service/util.rs

@ -4,9 +4,9 @@ domain:
store_dir_path: /tmp/domani_dev_env/domain
builtins:
foo:
kind: proxy
kind: http_proxy
url: http://127.0.0.1:9000
request_http_headers:
request_headers:
- name: x-foo
value: BAR
- name: host

@ -63,15 +63,12 @@ domain:
# kind: git
# url: "https://somewhere.com/some/repo.git"
# branch_name: main
# public: false
#
# # Which protocols to serve the domain on. The given list overwrites the
# # default, which is to serve on all available protocols.
# #serve_protocols:
# #- protocol: http
# #- protocol: https
# # If true then the built-in will be included in the web interface's
# # domain list, but will not be configurable in the web interface
# public: false
# An example built-in domain backed by a reverse-proxy to some other
# An example built-in domain backed by an HTTP reverse-proxy to some other
# web-service. Requests to the backing service will automatically have
# X-Forwarded-For and (if HTTPS) X-Forwarded-Proto headers added to them.
#
@ -80,23 +77,19 @@ domain:
# * dns.resolver_addr is ignored and the system-wide dns is used
#
#proxy.example.com:
# kind: proxy
# kind: http_proxy
# url: "http://some.other.service.com"
#
# # Extra headers to add to requests being proxied
# request_http_headers:
# # Extra headers to add to proxied requests
# request_headers:
# - name: Host
# value: "yet.another.service.com"
# - name: X-HEADER-TO-DELETE
# value: ""
#
# # If true then the built-in will be included in the web interface's
# # domain list, but will not be configurable in the web interface
# public: false
#
# # Which protocols to serve the domain on. The given list overwrites the
# # default, which is to serve on all available protocols.
# #serve_protocols:
# #- protocol: http
# #- protocol: https
service:

@ -248,7 +248,7 @@ impl Manager for ManagerImpl {
) -> Result<util::BoxByteStream, GetFileError> {
let settings = self.domain_store.get(domain)?.settings;
if let origin::Descr::Proxy { .. } = settings.origin_descr {
if let origin::Descr::HttpProxy { .. } = settings.origin_descr {
return Err(unexpected::Error::from("origin is proxy, can't serve file").into());
}

@ -79,7 +79,7 @@ async fn main() {
}
for (domain, builtin_domain) in &config.domain.builtins {
if let domani::origin::Descr::Proxy { ref url, .. } =
if let domani::origin::Descr::HttpProxy { ref url, .. } =
builtin_domain.settings.origin_descr
{
if let Err(e) = domani::origin::proxy::validate_proxy_url(url) {

@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct DescrProxyHttpHeader {
pub struct DescrHttpProxyHeader {
pub name: String,
pub value: String,
}
@ -15,10 +15,10 @@ pub enum Descr {
#[serde(rename = "git")]
Git { url: String, branch_name: String },
#[serde(rename = "proxy")]
Proxy {
#[serde(rename = "http_proxy")]
HttpProxy {
url: String,
request_http_headers: Vec<DescrProxyHttpHeader>,
request_headers: Vec<DescrHttpProxyHeader>,
},
}
@ -38,13 +38,13 @@ impl Descr {
h_update(url);
h_update(branch_name);
}
Descr::Proxy {
Descr::HttpProxy {
url,
request_http_headers,
request_headers,
} => {
h_update("proxy");
h_update(url);
for h in request_http_headers {
for h in request_headers {
h_update("header");
h_update(&h.name);
h_update(&h.value);

@ -30,17 +30,17 @@ pub async fn serve_http_request(
mut req: hyper::Request<hyper::Body>,
req_is_https: bool,
) -> unexpected::Result<hyper::Response<hyper::Body>> {
let (url, request_http_headers) = if let origin::Descr::Proxy {
let (url, request_headers) = if let origin::Descr::HttpProxy {
ref url,
ref request_http_headers,
ref request_headers,
} = settings.origin_descr
{
(url, request_http_headers)
(url, request_headers)
} else {
panic!("non-proxy domain settings passed in: {settings:?}")
};
for header in request_http_headers {
for header in request_headers {
let name: HeaderName = header
.name
.as_str()

@ -178,7 +178,7 @@ impl<'svc> Service {
};
// if the domain is backed by a proxy then that is handled specially.
if let origin::Descr::Proxy { .. } = settings.origin_descr {
if let origin::Descr::HttpProxy { .. } = settings.origin_descr {
return origin::proxy::serve_http_request(&settings, client_ip, req, req_is_https)
.await
.unwrap_or_else(|e| {

@ -56,7 +56,7 @@ impl TryFrom<domain::Settings> for FlatDomainSettings {
res.domain_setting_origin_descr_git_url = Some(url);
res.domain_setting_origin_descr_git_branch_name = Some(branch_name);
}
origin::Descr::Proxy { .. } => {
origin::Descr::HttpProxy { .. } => {
return Err(unexpected::Error::from(
"proxy origins not supported for forms",
));

Loading…
Cancel
Save