Skip to content

Commit bab1bd5

Browse files
committed
change markdown
1 parent 08e73df commit bab1bd5

File tree

7 files changed

+38
-96
lines changed

7 files changed

+38
-96
lines changed

docs/develop/change-log.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Change Log
2-
2+
### Version 3.0.0
3+
- rewrite, remove warp and cors, openTelemetry.
4+
- bump deps.
35
### Version 2.4.1
46
- conf: spa-server: `cors` value bool to array string.
57
- improve: bump deps version.

docs/guide/break-changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Break Changes
2+
## V3.0.0
3+
* spa-server: remove cors, acme, openTelemetry, cache config, remove hot reload.
24
## V2.4.1
35
* spa-server: `cors` value bool to array string.
46
## V2.4.0(2024-08-04)

docs/guide/spa-client-command-line.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ spa-client -c $CONFIG_PATH release $DOMAIN $OPT_VERSION
3838
# get info of the specific domain or all domain, just like the admin server http api.
3939
spa-client -c $CONFIG_PATH info $OPT_DOMAIN
4040

41-
# reload spa-server, this is used to reload https cert
42-
spa-client -c $CONFIG_PATH reload
4341

4442
# delete deprecated domain files
4543
spa-client -c $CONFIG_PATH delete $OPT_DOMAIN $OPT_MAX_RESERVE

docs/guide/spa-server-configuration.md

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The config default path is `./config.toml`, you can change it by environment `SP
1212

1313
```toml
1414
## directory to store static web files. if you use docker, please mount a persistence volume for it.
15-
file_dir = "/data"
15+
file_dir = "./data"
1616

1717
## enable cors, default is none, if cors is [], then all cors is ok.
1818
## Access-Control-Allow-Origin: $ORIGIN
@@ -32,51 +32,6 @@ addr = "0.0.0.0"
3232
## it would the port would be https.external_port(https.external_port should be defined), otherwise is false
3333
# redirect_https = true
3434

35-
# [https]
36-
# port = 443 # https bind address
37-
# addr = "0.0.0.0"
38-
## port when serving public network,default is https port. external_port should not be 0.
39-
# external_port = 443
40-
41-
## if set true, http server(80) will send client
42-
## status code:301(Moved Permanently) to tell client redirect to https
43-
44-
## default value for https ssl
45-
# [https.ssl]
46-
# private = "private.key path" # private ssl key
47-
# public = "public.cert path" # public ssl cert
48-
49-
## acme config, it doest not support run with https.ssl config.
50-
# [https.acme]
51-
## emails to Let's Encrypt needs to interact.
52-
# emails = ["mailto:[email protected]"]
53-
54-
## directory to store account and certificate
55-
## optional, default is ${file_dir}/acme
56-
# dir = "/data/acme"
57-
58-
## ci / stage / prod, default is prod, ci is just for CI test with Pebble, don't use it.
59-
# type = prod
60-
61-
## default cache config
62-
[cache]
63-
## if file size > max_size, it will not be cached. default is (10MB).
64-
# max_size = 10_000_000
65-
## gzip compression for js/json/icon/json, default is false,
66-
## only support gzip algo, and only compress cached files,
67-
## be careful to set it true
68-
# compression = false
69-
70-
## http header Cache-Control config,
71-
## optional, if not set, won't sender this header to client
72-
# [[cache.client_cache]]
73-
## 30day
74-
# expire = '30d'
75-
# extension_names = ['icon', 'gif', 'jpg', 'jpeg', 'png', 'js']
76-
# [[cache.client_cache]]
77-
# expire = '0'
78-
# extension_names = ['html']
79-
8035
## admin server config
8136
## admin server don't support hot reload. the config should not change.
8237
## optional, and it's disabled by default.
@@ -109,18 +64,4 @@ addr = "0.0.0.0"
10964
## it would the port would be https.external_port(https.external_port should be defined), otherwise is false
11065
# redirect_https = 443
11166

112-
## this would be usefully when set https.acme
113-
# disable_acme = false
114-
# [domains.https.ssl]
115-
116-
# [domains.cache]
117-
# max_size = 10_000_000
118-
# compression = false
119-
# [[domains.cache.client_cache]]
120-
# expire = '30d' # 30day
121-
# extension_names = ['icon', 'gif', 'jpg', 'jpeg', 'png', 'js']
122-
123-
124-
# [openTelemetry]
125-
# endpoint = "http://localhost:4317"
12667
```

docs/guide/spa-server-https.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/index.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ SPA.
2525

2626
## Feature
2727

28-
- Built with Hyper and Warp, fast and small!
29-
- SSL with Rustls.
30-
- Memory cache, client cache and compression(gzip).
28+
- Built with Hyper and Salvo, fast and small!
3129
- Static web version control, you can regress or release new version easily.
32-
- Hot reload support(Mac and Linux, by reused port).
33-
- CORS support.
34-
- Http auto redirect to https.
3530
- Docker support(compressed size: 32M).
3631
- Provide command line/npm package to deploy spa.
3732
- Multiple configs for different domain and Multiple SPA in on domain.

server/src/admin_server.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,36 @@ use crate::config::{get_host_path_from_domain, AdminConfig};
22
use crate::domain_storage::DomainStorage;
33
use delay_timer::prelude::*;
44
use salvo::prelude::*;
5+
use serde::{Deserialize, Serialize};
56
use std::collections::HashMap;
67
use std::sync::Arc;
78

9+
#[derive(Debug, Clone, Deserialize, Serialize)]
10+
struct BearerValidator {
11+
token: String,
12+
}
13+
14+
#[async_trait]
15+
impl Handler for BearerValidator {
16+
async fn handle(
17+
&self,
18+
req: &mut Request,
19+
depot: &mut Depot,
20+
res: &mut Response,
21+
ctrl: &mut FlowCtrl,
22+
) {
23+
match req.headers().get("Authorization") {
24+
Some(value) if value == &self.token => {
25+
ctrl.call_next(req, depot, res).await;
26+
}
27+
_ => {
28+
res.status_code(StatusCode::UNAUTHORIZED);
29+
ctrl.skip_rest();
30+
}
31+
}
32+
}
33+
}
34+
835
pub struct AdminServer {
936
conf: Arc<AdminConfig>,
1037
domain_storage: Arc<DomainStorage>,
@@ -28,7 +55,10 @@ impl AdminServer {
2855
}
2956

3057
fn routes(&self) -> Router {
31-
Router::with_hoop(
58+
Router::with_hoop(BearerValidator {
59+
token: format!("Bearer {}", self.conf.token),
60+
})
61+
.hoop(
3262
affix_state::inject(self.domain_storage.clone())
3363
.inject(self.conf.clone())
3464
.inject(self.host_alias.clone()),

0 commit comments

Comments
 (0)