serve

    Minimal static HTTP file server for MoonX.

    command-line
    moonx
    wasm
    Download zip
    Author
    Version
    0.1.6
    License
    Apache-2.0
    Last updated
    3 days ago
    Downloads
    127

    No dependencies

    #serve

    Serve a local directory over HTTP through MoonX.

    #Usage

    moonx cli/serve public moonx cli/serve --host 127.0.0.1 --port 8080 public

    Default to the current directory on 127.0.0.1:8000. Serve regular files with GET/HEAD and directory index.html files; print the bound address to stderr.

    #Common options

    OptionDescription
    -h, --helpShow help.
    -V, --versionShow the version.
    --host VALUENumeric IPv4 or IPv6 listen address. Default: 127.0.0.1.
    -p VALUE, --port VALUEListen port. Use 0 to choose an available port. Default: 8000.

    #Library

    The cli/serve module includes the Wasm library cli/serve/static_files. Construct a Directory::Directory(path) for each site, then call its serve method from a moonbitlang/core/async/http request handler. Instances may share a listener or use separate listeners; routing, access policy and cancellation belong to the caller. See the library example.

    #Notes

    • Every readable file under the selected root, including hidden files, can be served. Use a trusted, stable directory; path checks do not guarantee confinement against concurrent filesystem replacement.
    • There is no directory listing, SPA fallback, upload, range, compression or TLS support. Paths and symlink targets must stay under the selected root.
    • Use numeric IP addresses; port 0 selects an available port. Launcher policy must allow reading the directory and binding the address.

    Build from source with the MoonBit 1.0 RC1 toolchain.

    See the compatibility guide for the supported profile.

    Source Files