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?
Undertowserver. So I guess I'll just override
cask.Main.mainand create the server directly. Though it would be nice for
DefaultHandlerto be exposed publicly without needing to extend
cask.Mainbecause now I only need
defaultHandlerfrom it :).
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 the
cask.endpointspackage, for example
cask.get). This information is contained in an
RoutesEndpointMetadataobject 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?
DispatchTrie[Map[String, …]]. It's the old structure inverted basically.
Hi! I am new to both Scala and Cask. I am creating a small solution using Cask to run on a local machine and need a way to start and stop the server on an ad-hoc basis.
Based on the examples in the Cask documentation, it seems that Cask is designed to always start automatically (either by extending cask.MainRoutes with the route definitions or extending cask.Main to include multiple route definitions).
Is there a way I can embed Cask into an application, from which I can control starting and stopping it as required?