Ballista is a official webframework for the Igropyr server with Express style.

install: raven install ballista

use: (import (ballista ballista))

get

procedure: (get path handler)

procedure: (get path middleware ... handler)

return: unspecified

get is used to build the get method route, accepting any number of router-level middleware.

handler accepts two arguments, the first one depends on the middleware processing results, such as header, path, query list without any middleware.

The second one is the exit function.

post

procedure: (post path handler)

procedure: (post path middleware ... handler)

return: unspecified

post is used to build the post method route, accepting any number of router-level middleware.

handler accepts two arguments, the first one depends on the middleware processing results, such as header, path, payload list without any middleware.

The second one is the exit function.

next

procedure:(next x)

procedure:(next x y z ...)

return: (lambda (f) (f x y z ...))

next is used to construct middleware.

It takes any number of arguments and returns a procedure that takes a callback function as argument.

next's arguments are used to call this callback function, the number of their arguments must be equal.

get-use

procedure: (get-use middleware)

get-use is used to set application layer middleware of get method.

It can be used multiple times to set up multiple middleware.

post-use

procedure: (post-use middleware)

post-use is used to set application layer middleware of post method.

It can be used multiple times to set up multiple middleware.

staticpath

procedure: (staticpath path)

return: unspecified

staticpath accept a string to set the server's static path, replacing call the Igropyr's procedure set.

Can be omitted.

listen-on

procedure: (listen-on ip)

procedure: (listen-on port)

procedure: (listen-on ip port)

return: unspecified

set the IP and port which the server listen on, replacing call the Igropyr's procedure listen.

Can be omitted.

server-on

procedure: (server-on)

return: unspecified

Used to start the web server, replacing call the Igropyr's procedure server.

Note that (server-on) must be called after get, post, staticpath and listen-on are set.

Constructing middleware

request -> application-level middleware -> router -> router-level middleware -> handler

Convention: All middleware takes two arguments, and calling procedure next by two arguments.

The first argument of the first middleware will receive the header, path, and query/payload list.

The first argument of other middleware is determined by the middleware before it.

The second argument is the exit function, and all middleware must pass the exit function.

Calling procedure next to pass data and exit functions to the next middleware or handler.

Calling the exit function to blocking access or jumping, it accepts a procedure as argument.

(define middleware
    (lambda (req return)
        (if <test>
            (next req return)
            (return handle403))))
about following procedure, see library Catapult

res

send

host?

user-agent?

accept-language?

accept-encoding?

cookie?

connection?

query-parser

results matching ""

    No results matching ""