Skip to content
Snippets Groups Projects
Unverified Commit bc1deea3 authored by Joschua Kesper's avatar Joschua Kesper
Browse files

Added `--local` option for easier testing

parent 3584e3fe
Branches
No related tags found
No related merge requests found
Pipeline #253243 passed
mod markov; mod markov;
use std::{fs, path::Path}; use std::{fs, path::Path, net::Ipv4Addr};
use anyhow::Result; use anyhow::Result;
use clap::{arg, Parser}; use clap::{arg, Parser};
...@@ -58,19 +58,24 @@ impl Api { ...@@ -58,19 +58,24 @@ impl Api {
struct Args { struct Args {
#[arg(short, long)] #[arg(short, long)]
file: String, file: String,
#[arg(short, long)]
local: bool,
} }
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> { async fn main() -> Result<()> {
let service = OpenApiService::new(Api::from_file(Args::parse().file)?, "mew", "1.0") let args = Args::parse();
let service = OpenApiService::new(Api::from_file(args.file)?, "mew", "1.0")
.server("http://czi.wtf"); .server("http://czi.wtf");
let app = Route::new() let app = Route::new()
.nest("/", service.clone()) .nest("/", service.clone())
.nest("/docs", service.clone().swagger_ui()); .nest("/docs", service.clone().swagger_ui());
println!("starting server on http://0.0.0.0:6969"); let bind_ip = if args.local { Ipv4Addr::new(127,0,0,1) } else { Ipv4Addr::new(0,0,0,0)};
Server::new(TcpListener::bind("0.0.0.0:6969")) println!("starting server on http://{}:6969", bind_ip);
Server::new(TcpListener::bind((bind_ip, 6969)))
.run(app) .run(app)
.await?; .await?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment