-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wacker: support serving an HTTP WebAssembly module
- Loading branch information
Showing
14 changed files
with
856 additions
and
240 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ mod delete; | |
pub use self::delete::*; | ||
mod logs; | ||
pub use self::logs::*; | ||
mod serve; | ||
pub use self::serve::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use anyhow::{anyhow, Result}; | ||
use clap::Parser; | ||
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; | ||
use tonic::transport::Channel; | ||
use wacker::{ModulesClient, ServeRequest}; | ||
|
||
const DEFAULT_ADDR: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8080); | ||
|
||
#[derive(Parser)] | ||
pub struct ServeCommand { | ||
/// Module file path | ||
#[arg(required = true)] | ||
path: String, | ||
/// Socket address for the web server to bind to | ||
#[arg(long = "addr", default_value_t = DEFAULT_ADDR )] | ||
addr: SocketAddr, | ||
} | ||
|
||
impl ServeCommand { | ||
/// Executes the command. | ||
pub async fn execute(self, mut client: ModulesClient<Channel>) -> Result<()> { | ||
match client | ||
.serve(ServeRequest { | ||
path: self.path.to_string(), | ||
addr: self.addr.to_string(), | ||
}) | ||
.await | ||
{ | ||
Ok(_) => Ok(()), | ||
Err(err) => Err(anyhow!(err.message().to_string())), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.