#modio #api #v0 #web-server #devices #matching #tls-enabled

app modio-localapi

modio-localapi, a tls-enabled web-server matching the /v0 modio-api for devices

1 unstable release

0.4.1 Nov 2, 2022

#1264 in HTTP server

AGPL-3.0-or-later

49KB
697 lines

Modio Localapi

Releases and versions

The version is checked into git with localapi/Cargo.toml and others, those should be bumped as according to Semver compatibility.

The versions uploaded ( binaries ) are based on the Git tag, which does NOT need to match the cargo versions.

Web framework

tide seems better suited:

https://github.com/http-rs/tide

tls settings here: https://github.com/http-rs/tide-rustls

Running tests

If you have problems running the tests or compiling due to modio-logger or loggerdb, try:

SQLX_OFFLINE=true cargo build
SQLX_OFFLINE=true cargo test

the SQLX_OFFLINE variable makes sqlx tools look in the library itself for the json data it needs to validate SQL queries.

Launching

"cargo run --" can be used instead of calling './target/debug/localapi'

Run once

cd localapi
RUST_LOG=debug systemfd --no-pid -s 127.0.0.1:4333 -- \
    cargo run --    --server-cert ../examples/fffbeec0ffee.crt \
                    --server-key ../examples/fffbeec0ffee.key \
                    --ca-cert ../examples/ca.modio.se.crt

With "cargo watch"

cd localapi
RUST_LOG=debug  systemfd --no-pid -s 127.0.0.1:4333 -- \
      cargo watch -x \
            'run -- --server-cert ../examples/fffbeec1ffee.crt  \
                    --server-key ../examples/fffbeec1ffee.key \
                    --ca-cert ../examples/ca.modio.se.crt'

Making api calls

curl --cacert ca.modio.se.crt \
        --key fffbeec0ffee.key \
        --cert fffbeec0ffee.crt  \
        --resolve fffbeec0ffee:4333:127.0.0.1 -v  \
        -H 'Content-Type: application/json' \
        -d '{"expected":"0", "target":"1", "audit":[]}' \
                        https://fffbeec0ffee:4333/v0/localhost/12.ADE4A7000000.A/config


curl --cacert ca.modio.se.crt \
        --key fffbeec0ffee.key \
        --cert fffbeec0ffee.crt  \
        --resolve fffbeec0ffee:4333:127.0.0.1 -v  \
                https://fffbeec0ffee:4333/v0/localhost/12.ADE4A7000000.A/history/1/2

curl --cacert ca.modio.se.crt \
        --key fffbeec0ffee.key \
        --cert fffbeec0ffee.crt  \
        --resolve fffbeec0ffee:4333:127.0.0.1 -v  \
                https://fffbeec0ffee:4333/v0/localhost/12.ADE4A7000000.A/history

curl --cacert ca.modio.se.crt \
        --key fffbeec0ffee.key \
        --cert fffbeec0ffee.crt  \
        --resolve fffbeec0ffee:4333:127.0.0.1 -v  \
                https://fffbeec0ffee:4333/v0/localhost/12.ADE4A7000000.A

curl --cacert ca.modio.se.crt \
        --key fffbeec0ffee.key \
        --cert fffbeec0ffee.crt  \
        --resolve fffbeec0ffee:4333:127.0.0.1 -v  \
                https://fffbeec0ffee:4333/v0/localhost

curl --cacert ca.modio.se.crt \
        --key fffbeec0ffee.key \
        --cert fffbeec0ffee.crt  \
        --resolve fffbeec0ffee:4333:127.0.0.1 -v  \
                https://fffbeec0ffee:4333/v0

Dependencies

~26–40MB
~730K SLoC