Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samueleaton/raze
Modular, light web framework for Crystal
https://github.com/samueleaton/raze
crystal
Last synced: about 2 months ago
JSON representation
Modular, light web framework for Crystal
- Host: GitHub
- URL: https://github.com/samueleaton/raze
- Owner: samueleaton
- License: mit
- Archived: true
- Created: 2017-04-01T00:11:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-02T01:20:02.000Z (almost 4 years ago)
- Last Synced: 2024-08-01T00:41:13.046Z (4 months ago)
- Topics: crystal
- Language: Crystal
- Homepage: https://razecr.com/
- Size: 3.77 MB
- Stars: 175
- Watchers: 12
- Forks: 6
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - raze - Modular, light web framework (Web Frameworks)
README
# Raze
> Raze for days.
## NOTICE: I am archiving this project. I have since built something even better which I've been using for a couple years (However, it isn't open sourced)
Raze is a lightweight HTTP framework with a focus on building APIs and containerized services. If you want a more general purpose framwork with static file serving, check out [Kemal](https://github.com/kemalcr/kemal).
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
raze:
github: samueleaton/raze
```## Usage
```ruby
require "raze"get "/hello" do |ctx|
"hello, world!"
endRaze.run
```Raze takes a modular-first approach to middlewares
```ruby
require "raze"# Define middlewares
class Authenticator < Raze::Handler
def call(ctx, done)
puts "Authenticate here..."
done.call
end
endclass DDoSBlocker < Raze::Handler
def call(ctx, done)
puts "Prevent DDoS attack here..."
done.call
end
endclass UserFetcher < Raze::Handler
def call(ctx, done)
# Fetch user record from DB here...
ctx.state["user_name"] = "Sam"
done.call
end
end# Define routes, attach middlewares
get "/api/**", [Authenticator.new, DDoSBlocker.new]get "/api/user/:user_id", UserFetcher.new do |ctx|
"hello, #{ctx.state["user_name"]}!"
endRaze.run
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request### TODO
#### Core
- [ ] Be able to run a stack of middlewares before the static file handler
- [ ] Remove all global scoping (e.g. `get "/"` -> `Raze.get "/"`)
- [ ] Live reload functionality for development
- [ ] Be able to define middlewares globally (for all routes)#### Middlewares
- [ ] Urlencoded and JSON body parser
- [ ] Multipart/form-data body parser
- [ ] Static asset caching
- should take a cache time interval and be able to take a path match regex
- [ ] Route caching
- be able to cache the response for a route for a predetermined time interval
- [ ] Favicon caching
- [ ] CORS response header
- [ ] Access logger
- [ ] Session tracking
- [ ] Proxy middleware
- [ ] Security Headers
- e.g. Node's [Helmet](https://www.npmjs.com/package/helmet)## Contributors
- [Sam Eaton](https://github.com/samueleaton) - creator, maintainer