Hello,
I've been trying out cask
and so far loving the simplicity!
However, I have a question regarding how to shut down cask
application correctly. Scenario is this: in the main object (extends cask.Main
) message consumer is created, this consumer runs in the main's thread. It basically polls a queue (java.util.concurrent.BlockingQueue
) and does some work. Now in the router object (extends cask.Routes
) on every request its body is put into this queue. So for example if queue consumer fails and throws an exception, I'd like for the whole application to stop. Not sure if it's a good approach but I've tried executionContext.shutdown
from within object extending cask.Main
but routes are still being served and JVM does not exit. So what's the correct way here?
Undertow
server. So I guess I'll just override cask.Main.main
and create the server directly. Though it would be nice for DefaultHandler
to be exposed publicly without needing to extend cask.Main
because now I only need defaultHandler
from it :).
The script from “http://localhost:8080/static/app.js” was loaded even though its MIME type (“”) is not a valid JavaScript MIME type.
And indeed, when I check the headers content type in the browser it is not set. How can set it in Cask? I tried naivelyscript(
type:= "text/javascript", src := "/static/app.js")
but it didn't make the warning disappear.
initialize()
in a cask Routes object, it will traverse all methods defined in the object and derive routing information for all methods annotated with an "endpoint" annotation (common endpoints are defined in thecask.endpoints
package, for example cask.get
). This information is contained in an RoutesEndpointMetadata
object and will be used by the final http request routing mechanism (essentially the code that instructs the webserver how to map HTTP requests to method calls)
I just tried the new version on 3.0 and I can't replicate com-lihaoyi/cask#30 any longer. I might as well close it.
However, one thing that struck me is that cask returns a 405 — method not allowed for undefined routes, if the method has not been used for at least one other route. It seems like this should be 404 instead?