All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Add
Lennarb::Plugin
module to manage the plugins in the project. Now, theLennarb
class is the main class of the project. - Add
Lennarb::Plugin::Base
class to be the base class of the plugins in the project. - Add simple guide to use
Lenn
plugins. See guides/plugins/readme.md for more details.
- Add
Lennarb::Router
module to manage the routes in the project. Now, theLennarb
class is the main class of the project.
- Remove
Lennarb::ApplicationBase
class from the project. Now, theLennarb
class is the main class of the project.
- Improve performance of the RPS (Requests per second), memory and CPU usage.
- Change the
finish
method fromLennarb
class to callhalt(@res.finish)
method to finish the response.
- Add
header
andoptions
methods toLennarb
andLennarb::ApplicatiobBase
.
- Fix Content-Length header to be the length of the body in the response.
- Change behavior of
Lennarb::ApplicationBase
class to be the base class of theLennarb
class. Now, theLennarb
class is a subclass ofLennarb::ApplicationBase
class.
That permits to create a new application with the Lennarb::ApplicationBase
class and use http methods to create the routes. Ex.
# app.rb
require 'lennarb'
class MyApp < Lennarb::ApplicationBase
get '/hello' do |req, res|
res.html('Hello World')
end
end
- Remove
Lennarb::Application
module from the project. Now, theLennarb
class is the main class of the project.
- Add
Lennarb::ApplicationBase
class to be the base class of theLennarb
class. Now, theLennarb
class is a subclass ofLennarb::ApplicationBase
class.
That permits to create a new application with the Lennarb::ApplicationBase
class and use http methods to create the routes. Ex.
# app.rb
require 'lennarb'
class MyApp
include Lennarb::ApplicationBase
get '/hello' do |req, res|
res.html('Hello World')
end
end
- Change the test/test_lenna.rb to test/test_lennarb.rb
- Change
add_route
method fromLennarb
class to__add_route
and remove from private section.
- Remove
zeitwerk
gem to load the files in the project. - Remove
console
gem to print the logs in the console. - Remove
Lenna
module. Now, theLennarb
class is the main class of the project. - Remove
Middleware
module. - Remove
CLI
module. - Remove
Cache
module
- Change
Lennarb::Application
class toLennarb
class. - Request class and Response class now are in
Lennarb
class - Change
Lennarb::Router
class toLennarb
class
- Improve performance of the RPS (Requests per second), memory and CPU usage. Now the performance is similar to the Roda.
-
Add
console
gem to print the logs in the console. -
Add CLI module to:
- Create a new project with
lennarb new
command. - Run the server with
lennarb server
command.
- Create a new project with
-
Add simple guide to create and run a project with Lennarb. See guides/command-line/readme.md for more details.
-
Add
Reload
middleware to reload the application in development environment. You can import and use this middleware in your application. Ex.
# app.rb
require 'lenna/middleware/default/reload'
app = Lenna::Application.new
app.use Lenna::Middleware::Default::Reload
In the next version, this middleware will be available by default in development environment.
- Add
root
method toLennarb
module to get the root path of the project. Ex.
# app.rb
Lennarb.root.join('app.rb')
# => /home/user/project/app.rb
- Add
zeitwerk
gem to load the files in the project.
- Remove
Logging
andErrorHandling
middlewares from any environment. Now, theses middlewares are only available in development environment.
- Change log level to
fatal
in test environment.
-
Update
README.md
with the new features. Move examples toguides
folder. -
Replace
rubocop
tostandard
gem to lint the code. -
Move
puma
gem to development dependencies. -
Use tabs instead of spaces to indent the code.
-
Add default middlewares to
Lennarb::Router
class. Now, theLennarb::Router
class has the following middlewares by default:Lennarb::Middleware::Default::Logging
Lennarb::Middleware::Default::ErrorHandling
-
Replace
assign_status
to=
on Response
response.status = 200
- Rename
Lenna::Base
toLenna::Application
and accept a block to build the routes. Ex.
Lenna::Application.new do |app|
app.get '/hello' do |req, res|
res.status = 200
res['Content-Type'] = 'text/plain'
res.body = 'Hello World'
end
app.post '/hello' do |req, res|
res.status = 200
res['Content-Type'] = 'text/plain'
res.body = 'Hello World'
end
end
- The Middleware app now implements Singleton pattern to manager state.
- Add
standard
gem to lint the code. - Add
maintenance
gropu toGemfile
with:- Add
bake-gem
gem to run the tasks. - Add
bake-modernize
gem to update the code to the latest Ruby version. - Add
utopia-project
gem to generate the project. - Add
bake-github-pages
to generate the GitHub Pages.
- Add
- Add
bake
gem to run the tasks. - Add
puma
gem to run the development server. - Add alias to
assign_header
to[]=
on Response. Now, you can use:
response['Content-Type'] = 'application/json'
- Add alias to
assign_body
to:body=
on Response. Now, you can use:
response.body = 'Hello World'
- Add alias to
assign_params
to:params=
on Request. Now, you can use:
request.params = { name: 'John' }
- Remove
listen
method to run development server. Now, you must be use.config.ru
file to run the development server. Ex.
# .config.ru
require 'lennarb'
app = Lennarb::Application.new do |app|
app.get '/hello' do |req, res|
res.status = 200
res['Content-Type'] = 'text/plain'
res.body = 'Hello World'
end
app.post '/hello' do |req, res|
res.status = 200
res['Content-Type'] = 'text/plain'
res.body = 'Hello World'
end
end
run app
- Remove Rakefile. Now, you must be use
bake
gem to run the tasks. Ex.
bundle exec bake test
- Fix default middlewares to
Lennarb::Router
class. Now, theLennarb::Router
class has the following middlewares by default:Lennarb::Middleware::Default::Logging
Lennarb::Middleware::Default::ErrorHandling
- Add
assign_params
method to Request class
- Internal docmentation methods
- Fix
post_params
from Resquest router class
- Add basic documentation for usage. See README.md for more details.
- Implemented a specific error handler for Content-Type related errors, enhancing the system's ability to respond appropriately based on whether the request Content-Type is JSON or HTML.
- Removed the debug gem from development dependencies, streamlining the development environment setup.
- Fixed a bug that prevented the correct reading of the Content-Type header in requests, ensuring proper handling of content types.
- Introduced
Array.wrap
extension to theArray
class for more reliable conversion of objects to arrays within the Lennarb router environment. This method ensures consistent array wrapping of single objects andnil
values.
- Refactored the
put_header
method to use theArray.wrap
method for more predictable header value handling. - Renamed methods to have a consistent
assign_
prefix to standardize the API interface:put_header
toassign_header
write_body
toassign_body
set_params
toassign_params
update_status
toassign_status