This is an example Sandstorm application which uses the raw Cap'n Proto-based Sandstorm API to serve a web UI without an HTTP server. Most apps instead use sandstorm-http-bridge
wrapping a traditional server, but this one does't.
You might want to write a Sandstorm app using the raw API if:
That said, you should prefer sandstorm-http-bridge
around a traditional HTTP server if:
make dev
.make dev
to disconnect.Note: You can ignore the bogus warning about getaddrinfo
and static linking -- the app will never actually call getaddrinfo
. We statically link the binary so that there's no need to include shared libs in the package, making it smaller and simpler.
You can use this code as a starting point for your own app.
sandstorm-pkgdef.capnp
, read the comments, and edit. At the very least you want to rename the app and set a new App ID.client
directory./var
. You can create files under /var
with any name, but you cannot create sub-directories (for now).make dev
to test.make
to build a distributable package package.spk
.Note that server.c++
has some "features" that you may feel inclined to modify:
/var
). Anyone can read (though they must of course first receive the secret URL from the owner). For many apps, it's more appropriate for everyone to have write access (again, provided they've received the URL). Search for canWrite
in the code, and getViewInfo
.Content-Type
headers are derived from file extensions, with only a small number of types supported. index.html
is the default file for a directory. You can probably do better.