|
| 1 | +# fishcake |
| 2 | + |
| 3 | +A HttpArena entry for **CodeGreen** — a 1:1 Kotlin port of the C# [GenHTTP](https://github.com/Kaliumhexacyanoferrat/GenHTTP) |
| 4 | +web server — running on its internal Netty-based engine. It is configured like the |
| 5 | +sibling [`genhttp-11`](../genhttp-11) entry, rebuilt on the port's webservice stack |
| 6 | +(Conversion + Reflection + Webservices + Layouting). |
| 7 | + |
| 8 | +## Stack |
| 9 | + |
| 10 | +- **Language:** Kotlin / JDK 21 |
| 11 | +- **Framework:** CodeGreen (Kotlin port of GenHTTP) |
| 12 | +- **Engine:** CodeGreen internal engine (non-blocking, Netty) |
| 13 | +- **Serialization:** kotlinx.serialization |
| 14 | +- **Database:** PostgreSQL via JDBC + HikariCP (queried directly, as `genhttp-11` uses Npgsql) |
| 15 | +- **Build:** Gradle composite build — the app pulls CodeGreen in via `includeBuild` |
| 16 | + |
| 17 | +## Endpoints |
| 18 | + |
| 19 | +| Endpoint | Method | Description | |
| 20 | +|----------|--------|-------------| |
| 21 | +| `/pipeline` | GET | Returns `ok` (plain text) | |
| 22 | +| `/baseline11` | GET | Sums query parameters `a` + `b` | |
| 23 | +| `/baseline11` | POST | Sums `a` + `b` + a value read from the body | |
| 24 | +| `/baseline2` | GET | Sums query parameters `a` + `b` | |
| 25 | +| `/json/{count}` | GET | Processes the first `count` dataset items; `?m=` scales each total (default 1) | |
| 26 | +| `/upload` | POST | Drains the request body, returns the byte count | |
| 27 | +| `/async-db` | GET | `price BETWEEN min AND max` range query (sequential scan) | |
| 28 | +| `/crud/items` | GET | Paged listing by category | |
| 29 | +| `/crud/items/{id}` | GET | Cached single-item read (`X-Cache: HIT\|MISS`) | |
| 30 | +| `/crud/items` | POST | Upsert, returns `201 Created` | |
| 31 | +| `/crud/items/{id}` | PUT | Partial update, `404` when the id is unknown | |
| 32 | + |
| 33 | +## Profiles |
| 34 | + |
| 35 | +Declared in `meta.json`: `baseline`, `pipelined`, `limited-conn`, `json`, `upload`, |
| 36 | +`async-db`, `crud`, `api-4`, `api-16`. |
| 37 | + |
| 38 | +**Not implemented** — these depend on modules the port does not provide yet, so they are |
| 39 | +left out of `meta.json`: |
| 40 | + |
| 41 | +- `json-comp` — response compression (Compression module) |
| 42 | +- `json-tls`, `baseline-h2`, `static-h2`, `baseline-h2c`, `json-h2c` — TLS / HTTP-2 |
| 43 | +- `static` — static file serving (Files module) |
| 44 | +- `echo-ws` — WebSockets module |
| 45 | +- `fortunes` — HTML templating |
| 46 | +- HTTP/3 and gRPC profiles |
| 47 | + |
| 48 | +## Notes |
| 49 | + |
| 50 | +- The single-item CRUD read uses an in-process 200 ms TTL cache-aside (mirrors the C# entry's `MemoryCache`). |
| 51 | +- `DATABASE_URL`, `DATASET_PATH` and `DATABASE_MAX_CONN` follow the standard HttpArena contract. |
| 52 | + Without `DATABASE_URL`, the database-backed endpoints degrade gracefully (empty results / `404`). |
| 53 | +- The Docker build clones CodeGreen from its `port` branch and builds it as a composite build, |
| 54 | + so that branch must contain the webservice stack (currently in PR — `dotnet-web-stack/CodeGreen`). |
| 55 | + |
| 56 | +## Build & run locally |
| 57 | + |
| 58 | +The app consumes CodeGreen as a composite build. Point at a local checkout: |
| 59 | + |
| 60 | +```sh |
| 61 | +./gradlew shadowJar -PcodegreenDir=/path/to/CodeGreen |
| 62 | +DATASET_PATH=../../data/dataset.json java -jar build/libs/fishcake.jar |
| 63 | +``` |
| 64 | + |
| 65 | +In Docker the CodeGreen checkout is cloned to `./codegreen` automatically (see `Dockerfile`). |
0 commit comments