Giter Site home page Giter Site logo

danreeves / grip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grip-framework/grip

0.0 2.0 0.0 834 KB

The microframework for writing powerful web applications.

Home Page: https://grip-framework.github.io/docs/

License: MIT License

Crystal 99.97% HTML 0.03%

grip's Introduction

The microframework for writing powerful web applications.

Notice:Versions bellow 3.0.0 are not maintained anymore.

Travis Status Actions Status

TechEmpower Benchmark

Docs CI Status

Chat on Gitter

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.

Motivation

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.

Features

  • 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.

Code example

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

Installation

Add this to your application's shard.yml:

dependencies:
  grip:
    github: grip-framework/grip

And run this command in your terminal:

shards install

API Reference

Documentation can be found on the official website of the Grip framework.

Contribute

See our contribution guidelines and read the code of conduct.

Contributors

Thanks

  • Kemal - Underlying routing, parameter parsing and filtering mechanisms.
  • Amber - Static file handler, ideas and inspiration.
  • Gitter - Technical help, feedback and framework design tips.
  • Crystal - Detailed documentation, examples.

grip's People

Contributors

grkek avatar whaxion avatar nilsding avatar vinyll avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.