From 37352f34f34eca7e555e010292ef7b117da652c7 Mon Sep 17 00:00:00 2001 From: lihaoyi Date: Wed, 5 Jun 2024 13:28:35 +0000 Subject: [PATCH] deploy: a6719f691a5ddb218490238ba8e9ff0f80968b1a --- index.html | 4 ++-- page/about-cask.html | 2 +- page/main-customization.html | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index cfc86f127e..79ae23b9b4 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ -Cask: a Scala HTTP micro-framework

Cask: a Scala HTTP micro-framework

Main Customization

Discord Chat
Patreon

+

Cask - a Scala HTTP micro-framework

Main Customization

Discord Chat
Patreon

package app
 object MinimalApplication extends cask.MainRoutes{
   @cask.get("/")
diff --git a/page/about-cask.html b/page/about-cask.html
index f842bc91da..324ef049a5 100644
--- a/page/about-cask.html
+++ b/page/about-cask.html
@@ -114,7 +114,7 @@
 .Styles-subtleLink{
   text-decoration: none;
 }
-

About Cask

Functions First

+

About Cask

Functions First

Inspired by Flask, Cask allows you to define your web applications endpoints using simple function defs that you already know and love, annotated with the minimal additional metadata necessary to work as HTTP endpoints.

It turns out that function defs already provide almost everything you need in a HTTP endpoint:

    diff --git a/page/main-customization.html b/page/main-customization.html index f3755fb59c..ab9130de2e 100644 --- a/page/main-customization.html +++ b/page/main-customization.html @@ -114,7 +114,7 @@ .Styles-subtleLink{ text-decoration: none; } -

    Main Customization

    Apart from the code used to configure and define your routes and endpoints, Cask also allows global configuration for things that apply to the entire web server. This can be done by overriding the following methods on cask.Main or cask.MainRoutes:

    def debugMode: Boolean = true

    +

    Main Customization

    Apart from the code used to configure and define your routes and endpoints, Cask also allows global configuration for things that apply to the entire web server. This can be done by overriding the following methods on cask.Main or cask.MainRoutes:

    def debugMode: Boolean = true

    Makes the Cask report verbose error messages and stack traces if an endpoint fails; useful for debugging, should be disabled for production.

    def main

    The cask program entrypoint. By default just spins up a webserver, but you can override it to do whatever you like before or after the webserver runs.

    def log

    A logger that gets passed around the application. Used for convenient debug logging, as well as logging exceptions either to the terminal or to a centralized exception handler.

    def defaultHandler

    @@ -122,4 +122,4 @@

    The host & port to attach your webserver to.

    def handleNotFound

    The response to serve when the incoming request does not match any of the routes or endpoints; defaults to a typical 404

    def handleEndpointError

    The response to serve when the incoming request matches a route and endpoint, but then fails for other reasons. Defaults to 400 for mismatched or invalid endpoint arguments and 500 for exceptions in the endpoint body, and provides useful stack traces or metadata for debugging if debugMode = true.

    def mainDecorators

    -

    Any cask.Decorators that you want to apply to all routes and all endpoints in the entire web application. Useful for inserting application-wide instrumentation, logging, security-checks, and similar things.


    About the Author: Haoyi is a software engineer, an early contributor to Scala.js, and the author of many open-source Scala tools such as Cask, the Ammonite REPL and FastParse.

    If you've enjoy using Cask, or enjoyed using Haoyi's other open source libraries, please chip in (or get your Company to chip in!) via Patreon so he can continue his open-source work


    \ No newline at end of file +

    Any cask.Decorators that you want to apply to all routes and all endpoints in the entire web application. Useful for inserting application-wide instrumentation, logging, security-checks, and similar things.


    About the Author: Haoyi is a software engineer, an early contributor to Scala.js, and the author of many open-source Scala tools such as Cask, the Ammonite REPL and FastParse.

    If you've enjoy using Cask, or enjoyed using Haoyi's other open source libraries, please chip in (or get your Company to chip in!) via Patreon so he can continue his open-source work


    \ No newline at end of file