wasmer_deploy_schema/schema/
http_router.rs1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use super::{entity::EntityDescriptorConst, WorkloadV2};
5
6#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
7pub struct HttpRouterSpecV1 {
8 pub domains: Option<Vec<String>>,
12
13 pub routes: Vec<HttpRouteV1>,
15}
16
17impl EntityDescriptorConst for HttpRouterSpecV1 {
18 const NAMESPACE: &'static str = "wasmer.io";
19 const NAME: &'static str = "HttpRouter";
20 const VERSION: &'static str = "1alpha1";
21 const KIND: &'static str = "wasmer.io/HttpRouter.v1alpha1";
22 type Spec = Self;
23 type State = ();
24}
25
26#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
28pub struct HttpRouteV1 {
29 pub name: Option<String>,
32
33 pub priority: Option<i64>,
37
38 #[serde(default)]
40 pub matches: Vec<HttpRouteMatch>,
41
42 pub handler: HttpRouteHandlerV1,
47}
48
49#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
50pub enum HttpRouteHandlerV1 {
51 #[serde(rename = "spawn")]
52 Spawn(WorkloadV2),
53}
54
55#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
56pub struct HttpRouteMatch {
57 pub path: Option<HttpRoutePathMatch>,
58 pub methods: Option<Vec<String>>,
59 pub headers: Option<Vec<HttpRouteHeaderMatch>>,
60}
61
62#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
63pub enum HttpRoutePathMatch {
64 #[serde(rename = "prefix")]
65 Prefix(String),
66 #[serde(rename = "exact")]
67 Exact(String),
68 #[serde(rename = "regex")]
69 Regex(String),
70}
71
72#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
73pub struct HttpRouteHeaderMatch {
74 pub header: String,
75 pub value: HttpRouteHeaderValueMatch,
76}
77
78#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
79pub enum HttpRouteHeaderValueMatch {
80 #[serde(rename = "exact")]
81 Exact(String),
82 #[serde(rename = "regex")]
83 Regex(String),
84}
85
86pub type HttpRouterV1 = super::Entity<HttpRouterSpecV1>;