tiny_proxy/config/
models.rs1use std::collections::HashMap;
2
3#[cfg(feature = "api")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone)]
7#[cfg_attr(feature = "api", derive(Serialize, Deserialize))]
8pub struct Config {
9 pub sites: HashMap<String, SiteConfig>,
10}
11
12#[derive(Debug, Clone)]
13#[cfg_attr(feature = "api", derive(Serialize, Deserialize))]
14pub struct SiteConfig {
15 pub address: String,
16 pub directives: Vec<Directive>,
17 #[cfg_attr(feature = "api", serde(skip_serializing_if = "Option::is_none"))]
19 pub tls: Option<TlsConfig>,
20}
21
22#[derive(Debug, Clone)]
24#[cfg_attr(feature = "api", derive(Serialize, Deserialize))]
25pub struct TlsConfig {
26 pub cert_path: String,
27 pub key_path: String,
28}
29
30#[derive(Debug, Clone)]
31#[cfg_attr(feature = "api", derive(Serialize, Deserialize))]
32pub enum Directive {
33 ReverseProxy {
34 to: String,
35 connect_timeout: Option<u64>,
36 read_timeout: Option<u64>,
37 },
38 HandlePath {
39 pattern: String,
40 directives: Vec<Directive>,
41 },
42 UriReplace {
43 find: String,
44 replace: String,
45 },
46 Header {
47 name: String,
48 value: Option<String>,
49 },
50 Method {
51 methods: Vec<String>,
52 directives: Vec<Directive>,
53 },
54 StripPrefix {
55 prefix: String,
56 },
57 Redirect {
58 status: u16,
59 url: String,
60 },
61 Respond {
62 status: u16,
63 body: String,
64 },
65}