GithubHelp home page GithubHelp logo

aristotelesbr / lennarb Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 2.0 936 KB

Lennarb is a lightweight, fast and easy for building modular web applications and APIS with Ruby.

Home Page: https://aristotelesbr.github.io/lennarb/

License: MIT License

Ruby 98.89% Shell 0.42% Dockerfile 0.69%
api rack ruby lennarb router bake

lennarb's Introduction

Lennarb

Lennarb is a lightweight, fast, and modular web framework for Ruby based on Rack. The Lennarb supports Ruby (MRI) 3.0+

Basic Usage

require "lennarb"

Lennarb.new do |router|
  router.get("/hello/:name") do |req, res|
    name = req.params[:name]
    res.html("Hello, #{name}!")
  end
end

Performance

1. Requests per Second (RPS)

RPS

See all graphs

Position Application 10 RPS 100 RPS 1.000 RPS 10.000 RPS
1 Lenna 126.252,36 108.086,55 87.111,91 68.460,64
2 Roda 123.360,37 88.380,56 66.990,77 48.108,29
3 Syro 114.105,38 80.909,39 61.415,86 46.639,81
4 Hanami-API 68.089,18 52.851,88 40.801,78 27.996,00

This table ranks the routers by the number of requests they can process per second. Higher numbers indicate better performance.

Plese see Performance for more information.

Usage

  • Getting Started - This guide covers getting up and running with Lennarb.

  • Performance - The Lennarb is very fast. The following benchmarks were performed on a MacBook Pro (Retina, 13-inch, Early 2013) with 2,7 GHz Intel Core i7 and 8 GB 1867 MHz DDR3. Based on jeremyevans/r10k using the following template build.

  • Plugin - You can create your plugins to extend the functionality of the framework.

  • Response - This is the response guide. The res object is used to send a response to the client. The Lennarb use a custom response object to send responses to the client. The res object is an instance of Lennarb::Response.

Developer Certificate of Origin

This project uses the Developer Certificate of Origin. All contributors to this project must agree to this document to have their contributions accepted.

Contributor Covenant

This project is governed by the Contributor Covenant. All contributors and participants agree to abide by its terms.

lennarb's People

Contributors

aristotelesbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ioquatix ahx

lennarb's Issues

Implement Content Negotiation in Router

Description

The router currently lacks content negotiation capabilities, which restricts us to serve only one response type. Implementing this feature will allow our application to handle different media types in responses based on the Accept headers in requests.

Tasks

  • Parse Accept headers to determine preferred media types.
  • Implement prioritization logic for media types.
  • Link media types to their respective renderers or templates.
  • Establish a default fallback media type.
  • Enable route-specific content negotiation customization.
  • Write tests to ensure content negotiation works as expected.

Acceptance Criteria

  • The application should respond with the correct media type based on the Accept header.
  • There should be a fallback for unsupported media types.
  • Content negotiation should be testable and documented.

Erro on response.json format

Description

error: unknown keyword: :data (ArgumentError)

Steps to reproduce

Just don't use keys literal like this:

res.json(foo: "bar")

when use

res.json({ foo: 'bar' })

when use res.json({foo: bar}) works normally

Routes with different variables on the same level do not work

Hi,

I noticed that when adding routes with dynamic and static fields on the same level the trie get's confused:

	router = Lennarb::RouteNode.new
	router.add_route(['foo', ':foo'], 'GET', proc { 'foo' })
	router.add_route(%w[foo special], 'GET', proc { 'special' })
	router.add_route(['foo', ':id', 'bar'], 'GET', proc { 'bar' })

	_, params = router.match_route(%w[foo 23], 'GET')
	assert_equal({ foo: '23' }, params) # Fails because params are {:id=>"23"} instead of {:foo=>"23"}

I have added a PR to illustrate this.

This is the same problem hanami-router has.

Thanks for publishing this gem. I think it's super nice.

Documentação em pt-BR

Descrição

Criar documentação básica que explique as funcionalidades principais do router e que forneça exemplos claros de uso.

Tarefas

  • Documentar as funcionalidades principais
  • Fornecer exemplos de código para cada funcionalidade
  • Assegurar que os exemplos são fáceis de entender e de reproduzir

Critérios de Aceitação

  • A documentação deve ser clara e concisa.
  • Exemplos de uso devem ser testáveis e funcionar corretamente.

A documentação pode ser feita usando uma versão do readme-pt-BR.md

Documentation EN

Description

We need basic documentation that explains the main features of our router and provides clear usage examples.

Tasks

  • Document the router's main features.
  • Provide code examples for each feature.
  • Ensure that examples are easy to understand and follow.

Acceptance Criteria

  • Documentation should be clear and concise.
  • Usage examples should be testable and work correctly.

Use the READE.md

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.