Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grip-framework/grip
The microframework for writing powerful web applications.
https://github.com/grip-framework/grip
crystal grip kemal microframework phoenix router routing web-framework websocket
Last synced: 8 days ago
JSON representation
The microframework for writing powerful web applications.
- Host: GitHub
- URL: https://github.com/grip-framework/grip
- Owner: grip-framework
- License: mit
- Created: 2019-12-22T08:42:30.000Z (almost 5 years ago)
- Default Branch: core
- Last Pushed: 2024-10-22T12:58:02.000Z (17 days ago)
- Last Synced: 2024-10-25T01:21:31.459Z (14 days ago)
- Topics: crystal, grip, kemal, microframework, phoenix, router, routing, web-framework, websocket
- Language: Crystal
- Homepage: https://grip-framework.github.io/docs/
- Size: 1.06 MB
- Stars: 277
- Watchers: 15
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-crystal - grip - The microframework for writing powerful web applications (Web Frameworks)
README
The microframework for writing powerful web applications.
Grip is a microframework for building RESTful web applications. 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 has integrated middleware called "pipes". Pipes can alter parts of the request/response context and then get passed to the actual endpoint. Grip's router is very similar to the router of the [Phoenix framework](https://github.com/phoenixframework/phoenix). And most of all: Grip is fast.
## Motivation
This project exists due to the fact that Kemal lacks one crucial part of a framework, a structure. An example for the absence of a structure can be found [here](https://github.com/iv-org/invidious/blob/5d8de5fde2dee11ee8feb63f0bce74d373eec56f/src/invidious.cr).
## Features
- HTTP 1.1 support.
- WebSocket RFC 6455 support.
- Built-in exceptions support.
- Parameter handling support.
- JSON serialization and deserialization support (fastest framework with JSON in Crystal).
- Middleware support.
- Request/Response context, inspired by [expressjs](https://github.com/expressjs/express).
- Advanced routing support.## Code example
Add this to your application's `application.cr`:
```ruby
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.
enddef 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")
.halt
end
endclass Application < Grip::Application
def initialize(environment : String)
# By default the environment is set to "development".
super(environment)scope "/api" do
scope "/v1" do
get "/", IndexController
get "/:id", IndexController, as: :index
end
end# Enable request/response logging.
router.insert(0, Grip::Handlers::Log.new)
end
endapp = Application.new(environment: "development")
app.run
```## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
grip:
github: grip-framework/grip
```And run this command in your terminal:
```bash
shards install
```## API Reference
Documentation can be found on the [official website of the Grip framework](https://grip-framework.github.io/docs/) or
the [CrystalDoc website](https://crystaldoc.info/github/grip-framework/grip/v2.0.3/index.html).## Contribute
See our [contribution guidelines](https://github.com/grip-framework/grip/blob/master/CONTRIBUTING.md) and read the [code of conduct](https://github.com/grip-framework/grip/blob/master/CODE_OF_CONDUCT.md).