HoLy is simple a HTTP-server Library for Racket.
Sorry, library in alpha stage! Be carefull API is unstable!
Pull requests are welcome!
We'll make web fucntional again!
You can install it with using console utillity raco:
raco pkg install https://github.com/nihirash/holy.git
Or with using DrRacket IDE.
#lang racket
(require HoLy)
(http/get "/"
(λ (req) "Welcome"))
(http/get "/article/:id"
(λ (req)
(let* ((id (request/param 'id)))
(string-append "This is article #" id))))
(server/set-port 8080)
(server/run)
Defines request handler for specified request type.
Parameters are url as string(with possibility usage of placeholders) and callback function.
Example:
(http/get "/article/:id"
(λ (req)
(let* ((id (request/param 'id)))
(string-append "This is article #" id))))
Gets request parameter's value(from get/post or placeholder parameter).
Parameter is name of parameter.
Gets cookie value.
Parameter is name of cookie.
Creates response. It have required parameter content and several rest parameters.
Default values are:
#:code [code 200]
#:message [message #"OK"]
#:seconds [seconds (current-seconds)]
#:mime-type [mime-type TEXT/HTML-MIME-TYPE]
#:headers [headers (list (make-header #"Cache-Control" #"no-cache"))]
Can be used for creating custom response statuses/placing new headers etc.
Response with 404 status.
Defines port that's be listened with http server
Run's server event loop