Skip to content

Commit

Permalink
update-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jan 14, 2024
1 parent 1cb3535 commit 32ff603
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:


generate_docs:
if: github.repository == 'com-lihaoyi/cask' && contains(github.ref, 'refs/tags/')
if: github.repository == 'com-lihaoyi/cask'
needs: publish-sonatype
runs-on: ubuntu-20.04
env:
Expand Down
11 changes: 6 additions & 5 deletions docs/pages/1 - Cask: a Scala HTTP micro-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ and pass them all into `cask.Main`.
$$$variableRoutes
You can bind path segments to endpoint parameters by declaring them as parameters. these are
You can bind path segments to endpoint parameters by declaring them as parameters. These are
either:
* A parameter of the same name as the variable path segment of the same name as you
(e.g. `postId` above),
(e.g. `:userName` above). This can be a `String,` or other primitive types like `Int`,
`Boolean`, `Byte`, `Short`, `Long`, `Float`, `Double`
* A parameter of type `segments: cask.RemainingPathSegments`, if you want to allow
the endpoint to handle arbitrary sub-paths of the given path
Expand Down Expand Up @@ -424,15 +425,15 @@ $$$todoDb
This example demonstrates how to use Cask to write a TodoMVC API server that
persists it's state in a database rather than in memory. We use the
[Quill](http://getquill.io/) database access library to write a `@transactional`
[ScalaSql](https://github.com/com-lihaoyi/scalasql/) database access library to write a `@transactional`
decorator that automatically opens one transaction per call to an endpoint,
ensuring that database queries are properly committed on success or rolled-back
on error. Note that because the default database connector propagates its
transaction context in a thread-local, `@transactional` does not need to pass
the `ctx` object into each endpoint as an additional parameter list, and so we
simply leave it out.
While this example is specific to Quill, you can easily modify the
While this example is specific to ScalaSql, you can easily modify the
`@transactional` decorator to make it work with whatever database access library
you happen to be using. For libraries which need an implicit transaction, it can
be passed into each endpoint function as an additional parameter list as
Expand All @@ -451,7 +452,7 @@ The following code snippet is the complete code for a full-stack TodoMVC
implementation: including HTML generation for the web UI via
[Scalatags](https://github.com/lihaoyi/scalatags), Javascript for the
interactivity, static file serving, and database integration via
[Quill](https://github.com/getquill/quill). While slightly long, this example
[ScalaSql](https://github.com/com-lihaoyi/scalasql/). While slightly long, this example
should give you a tour of all the things you need to know to use Cask.
Note that this is a "boring" server-side-rendered webapp with Ajax interactions,
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/3 - About Cask.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ uses the [Mill](https://github.com/lihaoyi/mill) build tool, comes bundled with
the [uPickle](https://github.com/lihaoyi/upickle) JSON library, and makes it
trivial to pull in libraries like
[Scalatags](https://github.com/lihaoyi/scalatags) to render HTML or
[Quill](https://github.com/getquill/quill) for database access.
[ScalaSql](https://github.com/com-lihaoyi/scalasql/) for database access.

Each of these are stable, well-known, well-documented libraries you may already
be familiar with, and Cask simply provides the HTTP/routing layer with the hooks
Expand Down
8 changes: 4 additions & 4 deletions example/variableRoutes/app/src/VariableRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ object VariableRoutes extends cask.MainRoutes{
}

@cask.get("/path") // GET allowing arbitrary sub-paths, e.g. HOST/path/foo/bar/baz
def getSubpath(remainingPathSegments: cask.RemainingPathSegments) = {
s"Subpath ${remainingPathSegments.value}"
def getSubpath(segments: cask.RemainingPathSegments) = {
s"Subpath ${segments.value}"
}

@cask.post("/path") // POST allowing arbitrary sub-paths, e.g. HOST/path/foo/bar/baz
def postArticleSubpath(remainingPathSegments: cask.RemainingPathSegments) = {
s"POST Subpath ${remainingPathSegments.value}"
def postArticleSubpath(segments: cask.RemainingPathSegments) = {
s"POST Subpath ${segments.value}"
}

initialize()
Expand Down
32 changes: 0 additions & 32 deletions notes.txt

This file was deleted.

0 comments on commit 32ff603

Please sign in to comment.