Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the prefix option to prepend a path to all URLs #37

Merged
merged 4 commits into from
Nov 22, 2022

Conversation

Angelmmiguel
Copy link
Contributor

@Angelmmiguel Angelmmiguel commented Nov 21, 2022

Introduce a new --prefix option to preped a string to all URLs (workers and static assets). This option receives a string that will be properly normalized by the application. If no option is provided, the default value will be "" (no prefix).

This is the outcome from the --help command:

~/W/o/webassembly-functionless ❯❯❯ cargo run -- --help

Wasm Workers Server is a blazing-fast self-contained server that routes HTTP requests to workers in your filesystem. Everything run in a WebAssembly sandbox

Usage: wws [OPTIONS] [PATH]

Arguments:
  [PATH]  Folder to read WebAssembly modules from [default: .]

Options:
      --host <HOSTNAME>  Hostname to initiate the server [default: 127.0.0.1]
  -p, --port <PORT>      Port to initiate the server [default: 8080]
      --prefix <PREFIX>  Prepend the given path to all URLs
  -h, --help             Print help information
  -V, --version          Print version information

Note that this string must use URI format (/X/Y) because it's not a filesystem path. However, I also considered the case that someone introduces a windows path (\X\Y). I considered it because it's easy to implement, but I may drop support in the future.

It closes #31

@Angelmmiguel Angelmmiguel added the 🚀 enhancement New feature or request label Nov 21, 2022
Copy link
Contributor

@assambar assambar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it!

src/router.rs Outdated Show resolved Hide resolved
@Angelmmiguel Angelmmiguel merged commit 7484a2c into main Nov 22, 2022
@Angelmmiguel Angelmmiguel deleted the 31-add-prefix-option branch May 8, 2023 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the prefix option to the CLI
3 participants