d2 icon indicating copy to clipboard operation
d2 copied to clipboard

HTTP server directly in binary

Open dkarlovi opened this issue 1 year ago • 3 comments

Currently, the playground repo contains a small Go app which responds to /render/* requests. That app could be inlined into the actual D2 binary.

Doing so would allow using the app in a "daemon mode", for example building a bunch of diagrams from a static site generator (SSG) by having the binary run in Docker and just build SVGs on demand like an utility / appliance.

Think Hugo in dev mode vs Hugo build.

dkarlovi avatar Apr 11 '24 13:04 dkarlovi

That's a good idea. Like Python's built-in simple http server.

There's a lot to do before this though so if someone with Go experience wants to give it a try, PRs welcome!

alixander avatar Apr 12 '24 01:04 alixander

@alixander when you say

There's a lot to do before this

I'm assuming you don't mean "blockers", you mean "other stuff with higher priority", right?

dkarlovi avatar Apr 12 '24 06:04 dkarlovi

Sorry yes. No blockers for this. Should be relatively straightforward to base off of https://github.com/terrastruct/d2/blob/master/d2cli/watch.go#L483C27-L483C45 . Definitely don't want any new dependencies (e.g. a web framework).

alixander avatar Apr 12 '24 14:04 alixander