jbang
jbang copied to clipboard
Implement quickserv in jbang
Is your feature request related to a problem? Please describe. Spotted https://github.com/jstrieb/quickserv today and really like the idea about making super easy to make a web service For learning/prototyping.
Describe the solution you'd like Jbang quickserv@jbangdev should be able to run what is in https://github.com/jstrieb/quickserv-examples but also allow jbang scripts.
Describe alternatives you've considered Could also look to submit to quickserv to grok .java using jbang style shebang.
See jbang quickserv@quintesse~experimental
, there's a quickserv
folder with some very simple examples.
sweet...even runs demo.java :)
but why jetty? :)
What else should I have used? :-)
I started out with Javelin, but it can't do what I needed (being able to serve static files and custom handlers from the same route) so I went one level deeper to Jetty (Javelin is a wrapper around Jetty).
Created an alternative implementation (based on my simple_httpd.java
) that only uses built-in Java types: https://github.com/quintesse/jbang-catalog/blob/master/experimental/quickserv2.java , but it doesn't (currently) handle form parameters etc, because that's not part of the basic Java support (AFAIK).
NB: Unfortunately both of them suffer from the same "issue", which you can see if you run the [test_timer.sh}(https://github.com/quintesse/jbang-catalog/blob/master/experimental/quickserv/test_timer.sh) example script. This script prints out a line each second but both implementations seem to buffer the first N (~20) lines and only after those have been received (and displayed) will you see the page update each second. I have not been able to figure out how to get rid of that buffering.
NB2: That's not really a big issue at all, it's just something that I would have liked to work perfectly because it allows for all kinds of cool possibilities. But I guess the current version is already good enough.