Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nihirash/holy
HoLy is simple http library for Racket language
https://github.com/nihirash/holy
http-server racket-lang racket-library rest-api waf web
Last synced: 3 months ago
JSON representation
HoLy is simple http library for Racket language
- Host: GitHub
- URL: https://github.com/nihirash/holy
- Owner: nihirash
- License: other
- Created: 2017-10-04T20:30:57.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-03T16:20:01.000Z (about 7 years ago)
- Last Synced: 2024-04-18T16:56:08.664Z (7 months ago)
- Topics: http-server, racket-lang, racket-library, rest-api, waf, web
- Language: Racket
- Size: 12.7 KB
- Stars: 12
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-racket - HoLy - HoLy is simple a HTTP-server Library for Racket. (Web Frameworks)
README
# HoLy
## What is it?
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!
## Installation
You can install it with using console utillity **raco**:
```
raco pkg install https://github.com/nihirash/holy.git
```Or with using DrRacket IDE.
## Usage
```racket
#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)
```## API
### http/get, http/post, http/delete, http/put
Defines request handler for specified request type.
Parameters are url as string(with possibility usage of placeholders) and callback function.
Example:
```racket
(http/get "/article/:id"
(λ (req)
(let* ((id (request/param 'id)))
(string-append "This is article #" id))))
```### request/param
Gets request parameter's value(from get/post or placeholder parameter).
Parameter is name of parameter.
### request/cookie
Gets cookie value.
Parameter is name of cookie.
### response/make
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/404
Response with 404 status.
### server/set-port
Defines port that's be listened with http server
### server/run
Run's server event loop
## Credits
* [z-song](https://github.com/z-song/raf/) is author Raf framework(HoLy is created by reading Raf sources).
* [nihirash](https://github.com/nihirash/) is author and maintainer of HoLy library