Skip to content

examples/net: add httphi versions of webserver and webstatic - #931

Merged
deadprogram merged 1 commit into
devfrom
examples-net-httphi
Oct 27, 2026
Merged

deadprogram merged 1 commit into
devfrom
examples-net-httphi

Conversation

@deadprogram

Copy link
Copy Markdown
Member

Adds webserver-httphi and webstatic-httphi. They do the same thing as the existing webserver and webstatic examples but use the heapless httphi router instead of net/http.

Size (flash / static RAM):

target / example net/http httphi
nano-rp2040 webserver 418 KB / 15.0 KB 139 KB / 7.8 KB
nano-rp2040 webstatic 477 KB / 17.5 KB 167 KB / 7.8 KB
matrixportal-m4 webstatic 445 KB / 18.9 KB 163 KB / 9.2 KB
wioterminal webserver 390 KB / 19.7 KB 134 KB / 12.5 KB
arduino-nano33 webserver does not fit 140 KB / 7.2 KB

httphi allocates its buffers once at startup and nothing per request.

lneto requires Go 1.24, so go.mod is bumped from 1.22.1 to 1.24.

Tested on nano-rp2040. Smoketest entries added.

@deadprogram
deadprogram requested a review from soypat October 23, 2026 22:28
@deadprogram

Copy link
Copy Markdown
Member Author

The smoke test fails because the webserver-httphi example does not fit in flash on arduino-nano33 (overflow of 174944 bytes).

The httphi package imports log/slog, which in turn imports encoding/json. TinyGo 0.43.0, which CI uses, does not remove that unused code, so the binary is about 430 KB. With TinyGo 0.44.0-dev the same example is 139 KB and builds fine.

Holding this PR until TinyGo 0.44 is released and CI picks it up.

@soypat

soypat commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Noslog build tag does not work to exclude the slog package? That would be an issue in lneto

@deadprogram

Copy link
Copy Markdown
Member Author

You are right, -tags=noslog works. With TinyGo 0.43.0 it brings arduino-nano33 webserver-httphi down to 169 KB so it fits. I added the tag to the httphi smoketest entries instead of waiting for 0.44.

Use the heapless httphi router from github.com/soypat/lneto instead of
net/http. This uses about a third of the flash and half the static RAM,
and lets webserver fit on the arduino-nano33.

Bumps go.mod to go 1.24 as required by lneto.
@deadprogram

Copy link
Copy Markdown
Member Author

@soypat PTAL

@soypat soypat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very strict allocation discipline, very nice. Also noticed a few things I want to keep in mind to possibly improve httphi ux.

@deadprogram

Copy link
Copy Markdown
Member Author

Thanks for review @soypat now merging.

@deadprogram
deadprogram merged commit 635418e into dev Oct 27, 2026
1 check passed
@deadprogram
deadprogram deleted the examples-net-httphi branch October 27, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants