crescent_wasm_demo

    A minimal Crescent web server that also builds for the wasm target.

    http
    server
    wasm
    example
    crescent
    Download zip
    Author
    Version
    0.1.1
    License
    Apache-2.0
    Last updated
    3 days ago
    Downloads
    37

    Dependencies

    #bobzhang/crescent_wasm_demo

    A minimal web server built with Crescent that targets wasm as well as native (supported_targets = "-all+native+wasm").

    Routes:

    • GET / — plain text greeting
    • GET /hello/:name — path parameter echo
    • GET /json — JSON response

    #Run

    moon run wasm_demo/cmd/main --target wasm moon run wasm_demo/cmd/main --target native

    #Test

    Handlers can be exercised without network I/O via @crescent.test_client:

    ///|
    async test "hello route" {
    let client = @test_client.TestClient(@crescent_wasm_demo.make_app())
    let res = client.get("/hello/wasm")
    inspect(res.body_text(), content="Hello, wasm!")
    }

    make_app

    fn make_app() ->
    App

    Builds the demo application: a few routes and nothing else.

    run

    async fn run(port~ : Int) -> Unit

    Serves the demo application on the given port.