The microframework for writing powerful web applications.
Notice:Versions bellow 3.0.0 are not maintained anymore.
It is designed to be modular and easy to use, with the ability to scale up to the limits of the Crystal programming language. It offers extensibility and it has integrated middleware called "pipes" which alter the parts of the request/response context and pass it on to the actual endpoint. It has a router which somewhat resembles that of Phoenix framework's router and most of all it is fast.
The existance of this project is due to the fact that Kemal lacks one crucial part of every successful framework, a structure. An example for the absence of structure can be found here.
- HTTP 1.1 support.
- WebSocket RFC 6455 support.
- Built-in exceptions support.
- Parameter handling support.
- JSON serialization and deserialization support.
- Built-in middleware support.
- Request/Response context, inspired by expressjs.
- Advanced routing support.
Add this to your application's application.cr
:
require "grip"
class IndexController < Grip::Controllers::Http
def get(context : Context) : Context
context
.put_status(200) # Assign the status code to 200 OK.
.json({"id" => 1}) # Respond with JSON content.
.halt # Close the connection.
end
def index(context : Context) : Context
id =
context
.fetch_path_params
.["id"]
# An optional secondary argument gives a custom `Content-Type` header to the response.
context
.json(content: {"id" => id}, content_type: "application/json; charset=us-ascii")
end
end
class Application < Grip::Application
def routes
pipeline :api, [
Pipes::PoweredByHeader.new
]
pipeline :web, [
Pipes::SecureHeaders.new
]
scope "/api/v1" do
pipe_through [:web, :api]
get "/", IndexController
end
get "/:id", IndexController, as: :index
end
end
app = Application.new
app.run
Add this to your application's shard.yml
:
dependencies:
grip:
github: grip-framework/grip
And run this command in your terminal:
shards install
Documentation can be found on the official website of the Grip framework.
See our contribution guidelines and read the code of conduct.
- Giorgi Kavrelishvili - creator and maintainer.
- nilsding - contributor
- Whaxion - contributor
- Vincent Agnano - contributor