object MinimalApplication extends cask.MainRoutes{
@cask.get("/")
def hello() = {
"Hello World!"
}
@cask.post("/do-thing")
def doThing(request: cask.Request) = {
request.text().reverse
}
initialize()
}
Cask is a simple Scala web framework inspired by Python's Flask project. It aims to bring simplicity, flexibility and ease-of-use to Scala webservers, avoiding cryptic DSLs or complicated asynchrony. Cask makes it easy to set up a website, backend server, or REST API using Scala
If you use Cask and like it, you will probably enjoy the following book by the Author:
Hands-on Scala has uses Requests-Scala extensively throughout the book, and has the entirety of Chapter 14: Simple Web and API Servers dedicated to the library. Hands-on Scala is a great way to level up your skills in Scala in general and Cask in particular.
Cask is profiled using the JProfiler Java Profiler, courtesy of EJ Technologies
@postJsonCached
to allow reference to the original body payload in @postJson
#123Properly decode URL parameters when passed as path segments or query params #114
Preserve leading slash when resolving static paths #111
Add cask.QueryParams
type to allow route methods to take arbitrary query parameters,
add cask.RemainingPathSegments
as replacement for subpath = true
#108
#109
#110
org.xerial:sqlite-jdbc
library in examples to version 3.41.2.1
to@staticResources
and @staticFiles
decorators now automatically infer
content types based on file extension@cask.options
decoratoractorContext
explicitly passed into every Routes case classgeny.Writable#httpContentType
and
geny.Writable#contentLength
delete
and patch
SameSite
cookie attributecask-actor
into its own repo and artifact,
https://github.com/lihaoyi/castorcask-actor
into a separate artifact, documented separately as
Cask ActorsMismatched decorator types applied to a single method is now a compile error
staticFiles
and staticResources
now allows you to specify response headers
Allow cask.decorators.compress
to be used as a cask.Routes
or cask.Main
decorator without crashing on websocket responses
Allow decorators to be defined and used for non-cask.Response
results
cask.WebsocketClientImpl
cask.WsClient
Routes#log
implicitcask.util
for Scala.jsconcurrent.ExecutionContext.global
in cask.Routes
by default, to be
overriden if necessarycask.Logger
interfacecask.WsHandler
and cask.WsActor
cask.Response
is now covariant./mill
bootstrap script