Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keynmol/scala-native-microhttpd-example
https://github.com/keynmol/scala-native-microhttpd-example
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/keynmol/scala-native-microhttpd-example
- Owner: keynmol
- Created: 2023-11-05T13:29:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-05T13:45:57.000Z (about 1 year ago)
- Last Synced: 2024-10-04T18:42:58.505Z (3 months ago)
- Language: Scala
- Size: 15.6 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Scala 3 Native ❤️ libmicrohttpd
I recently discovered there's a relatively small HTTP server library
called microhttpd by the GNU project: https://www.gnu.org/software/libmicrohttpd/manual/html_node/index.htmlThis small project contains:
- `microhttpd.bindings.scala` - Microhttpd bindings generated by [sn-bindgen](https://sn-bindgen.indoorvivants.com/quickstart/index.html), my binding generator
- `run.server.scala` - the logic to run a simple web server that responds with JSON
- `DangerZone.scala` - absolutely horrific experiment in memory management to
circumvent combined limitations of Zone from Scala Native and C's function pointers. I'm pursuing a life long goal to have a CVE named after me.## Running
This is a [Scala CLI](https://scala-cli.virtuslab.org/) project.
Personally, I run it using my [sn-vcpkg](https://github.com/indoorvivants/sn-vcpkg#scala-cli) project to avoid messing with flags by hand:
```
cs launch com.indoorvivants.vcpkg:sn-vcpkg_3:latest.release -- \
scala-cli libmicrohttpd -- run .
```But if you know what you're doing, "just" install "libmicrohttpd" and adjust the linking flags required to run it:
```
scala-cli run . --native-linking -lmicrohttpd
```