Skip to content

Commit

Permalink
added readme.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
diasbruno committed Oct 13, 2024
1 parent 144e4b3 commit 434f2a2
Showing 1 changed file with 71 additions and 2 deletions.
73 changes: 71 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,78 @@
# wst (web server tools)

Many tools to help you build a web application in Common Lisp.
Tools to help you build a web application in Common Lisp.

### available systems

NOTE: This is not even close to alpha quality (but it's in production).
#### wst.routing

Main system. Manages the routes used in a application.

```lisp
(add-route 'something "/something" :GET (lambda () "something"))
(add-route 'post-something "/something/:number" :POST (lambda () "something"))
(remove-route 'something)
(condition-handler (lambda (request response err) nil))
;; anything else that is a GET request is handled like this.
(any-route-handler :GET (lambda (request reponse) nil))
(route-uri-of (find-route-by-name 'post-something) (list 1))
;; => "/something/1"
```

#### wst.routing.dsl

A dsl to build passes (filters and middlewares).

```lisp
(defparameter api
`(wrap
:before (list acquire-request-connection manage-session)
:after (list http-response-cookies->set-cookie release-request-connection)
:route (resource "/api/v1"
(wrap
:before check-if-user-already-authenticated
:route (group
(route :post api-sign-up "/sign-up" api-sign-up-controller)
(route :post api-log-in "/log-in" api-log-in-controller)
(route :post api-log-out "/log-out" api-log-out-controller)))
(wrap
:before ,(require-authorization (niav.configurations:jwt-public-key))
:route (group
(group
(wrap
:before add-session-csrf
:route (group
(route :POST create-user "/user" create-user-responder)
(route :PATCH edit-user "/user/:user-id" edit-user-responder)))
(route :GET find-user "/user/:user-id" find-user-responder)
(route :DELETE delete-user "/user/:user-id" delete-user-responder)
(route :GET list-account-users "/users" list-account-users-responder))
(group
(wrap
:before add-session-csrf
:route (group
(route :POST create-group "/group" create-group-responder)
(route :PATCH edit-group "/group/:group-code" edit-group-responder))
(route :GET find-group "/group/:group-code" find-group-responder)
(route :DELETE delete-group "/group/:group-code" delete-group-responder)
(route :GET list-account-groups "/groups" list-account-groups-responder))))))))
```

This will build a list of routes in the following form.

```lisp
#<route uri=/api/v1/sign-up
method=:POST
callback=(compose acquire-request-connection
manage-session
check-if-user-already-authenticated
api-sign-up-controller
http-response-cookies->set-cookie
release-request-connection)>
```

# license

Expand Down

0 comments on commit 434f2a2

Please sign in to comment.