Skip to content

Commit

Permalink
refactor: simplify service spec
Browse files Browse the repository at this point in the history
  • Loading branch information
zenlex committed Mar 10, 2024
1 parent a4fa4af commit 10c8fff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions SERVICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ To register a service with the gateway to make it available for use from the [Tu
```toml
[services.name] # where 'name' is a unique kebab-case name for your service
path="/myservice" # unique path the frontend will make a request to at /api[path]
target_host="https://my-service.default.svc.cluster.local" # the host for the service
target_port=8080 # the target port for your service
host="https://my-service.default.svc.cluster.local" # the host for the service
port=8080 # the target port for your service
```
- add an entry for your service in the list below with a brief description of your service and a link to the documentation

Expand Down
15 changes: 9 additions & 6 deletions gateway_config.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
auth_url = "example.com"
whitelist = [
"localhost/*"
]

[services.users]
path="/users"
target_service="http://user-service.default.svc.cluster.local"
target_port=8080
host="http://user-service.default.svc.cluster.local"
port=8080

[services.orders]
path="/orders"
target_service="http://order-service.default.svc.cluster.local"
target_port=8080
host="http://order-service.default.svc.cluster.local"
port=8080

[services.test]
host="https://google.com"
port=443
5 changes: 2 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use std::{fs::File, io::Read};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ServiceConfig {
pub path: String,
pub target_host: String,
pub target_port: u32,
pub host: String,
pub port: u32,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down

0 comments on commit 10c8fff

Please sign in to comment.