Catapult is a official webframework for the Igropyr server.
install: raven install catapult
use: (import (catapult catapult))
req
procedure: (req (request_path handler) ...)
return: list
req
accepts any number of s expressions.
request_path
must be a string, and handler
must be a procedure.
The returned list is structured as follows:
((request_path . handler)
...)
res
procedure: (res content)
procedure: (res status content)
procedure: (res type content)
procedure: (res status type content)
procedure: (res status type cookie content)
return: string
res
can take one to three arguments and preparer a string with a standard http header.
When res
received two arguments and the first argument is int, the first argument is marked as status code.
When res
received two arguments and the first argument is a string, the first arguments is marked as return type.
When res received three arguments, the first two arguments are sequentially marked as status code, return type. The first argument must be int.
In these cases, and when res received one arguments, content
may be a list or a string.
If content
is a list, its first element is marked as cookie and the second as response content.
If content
is a string, it's marked as response content and cookie will be ""
.
When res received four arguments, the arguments are sequentially marked as status code, return type, cookie and response content. In this case, the first argument must be int and the others must be string.
Unmarked messages will use the default status: 200 type: text/html
Usually use to build the callback for Igropyr's procedure request
instead of response
.
send
procedure: (send file_path)
procedure: (send type file_path)
return: string
send
can take one or two arguments.
when send
received one arguments, is marked as file path.
When send
received two arguments the first arguments is marked as return type and the second as file path.
Unmarked MIME type will be automatelly detected.
Usually use to build the callback for Igropyr's procedure request
instead of sendfile
.
router
procedure: (router route_list path)
return: procedure
Router accepts a list of routing information and a request path string, returns the matching path corresponding procedure.
The router supports calls to the Igropyr’s procedure par to fuzzy query, find the first traversal to match the full search,
When the return of all matching queries is empty, router fuzzy query with * included path, please write the route which containing * after which without to ensure high efficiency.
When the value is obtained will exit and return value, so please put "/*" at the end of the routing table.
The routing information list structure is:
((request_path . handler)
...)
Where request_path must be a string, and handler
must be a procedure.
host?
procedure: (host? http-header)
return: string
Use to return host
information in http-header.
user-agent?
procedure: (user-agent? http-header)
return: string
Use to return user-agent
information in http-header.
accept-language?
procedure: (accept-language? http-header)
return: string
Use to return accept-language
information in http-header.
accept-encoding?
procedure: (accept-encoding? http-header)
return: string
Use to return accept-encoding
information in http-header.
cookie?
procedure: (cookie? http-header)
return: string
Use to return cookie
information in http-header.
connection?
procedure: (connection? http-header)
return: string
Use to return connection
information in http-header.
query-parser
procedure: (query-parser query key-value-spliter group-spliter)
return: association list
Use to convert query
into a association list
.