Awesome
Brook framework
Overview
Brook is a cross-platform microframework which helps to develop web Pascal applications built by Delphi or Lazarus IDE and Free Pascal. Its core has been developed using the Sagui library, that's why it is so fast, compact and useful to run on embedded systems.
Features
- Three threading modes:
- Event-driven - single-thread + polling.
- Threaded - one thread per request.
- Polling - pre-allocated threads.
- Isolated request - request processed outside main thread.
- Fast path routing that supports:
- Regular expression with JIT optimization.
- Binary search for path entry-points.
- HTTP compression:
- HTTP cookies:
- Providing classes which handles server side cookies.
- HTTPS support:
- Data encryption through GnuTLS library.
- Dual stack:
- IPv4 and IPv6 on top of a single socket.
- Basic authentication:
- For standard login using username and password.
- Upload/download:
- Static body and payload.
- Content streaming for real-time applications.
- Small and large files transferring.
- Mathematical expression evaluator:
- Arithmetic, bitwise and logical operators.
- Variables allocation at build and/or run time.
- Macro support to define functions at run time.
- Extendable with custom functions.
- Error handling with error kind and position.
- Media types:
- Resolving media types (MIME) in any supported platform.
- Logging:
- Allowing to generate logs in console or files.
- String buffer:
- For fast operations involving strings.
- String map:
- Hashed lists for key-value mapping.
- And more:
- Discover more features by playing with our examples.
Examples
The example below shows a minimal hello world
HTTP server:
type
THTTPServer = class(TBrookHTTPServer)
protected
procedure DoRequest(ASender: TObject; ARequest: TBrookHTTPRequest;
AResponse: TBrookHTTPResponse); override;
end;
procedure THTTPServer.DoRequest(ASender: TObject; ARequest: TBrookHTTPRequest;
AResponse: TBrookHTTPResponse);
begin
AResponse.Send('Hello world', 'text/plain', 200);
end;
begin
with THTTPServer.Create(nil) do
try
Port := 8080;
Open;
if not Active then
Exit;
WriteLn('Server running at http://localhost:', Port);
ReadLn;
finally
Free;
end;
end.
There are other examples available in the Examples
directory.
Downloading
All stable releases are available to download via GetIt, OPM and GitHub releases page.
We strongly recommend you to install Brook using GetIt or OPM, however, if you want to download the very latest source from the Git repository, do this:
git clone https://github.com/risoflora/brookframework.git
It will create a directory named brookframework
filled with the source code.
Documentation
The documentation has been written in PasDoc and is available in HTML format at brookframework-docs.
Targets
Successfully tested on:
- Windows
- Linux
- Raspbian/Android
compiled using:
- Delphi XE family (Rio)
- Lazarus / Free Pascal (Lazarus 2.0+ / FPC 3.2+)
Versioning
Starting from the version 1.0.0, Brook follows the SemVer rules regarding API changes with backwards compatibility across major releases.
Contributing
Brook framework is totally open source and would not be possible without our contributors. If you want to submit contributions, please fork the project on GitHub and send a pull request. You retain the copyright on your contributions.
Donations
Many open source projects, large and small, receive donations to encourage their authors, therefore, it would be not different in Brook.
All money collected from donations are invested to the purchase of study materials. This way, directly or indirectly, all knowledge acquired in the studies influence the spread of this project.
If you want to support this project, please choose one of the options below to make a donation.
(For those who would like to donate in Brazilian BRL, it can be done by a identified bank deposit or via PayPal Brazil.)
Check the list of all donors that lovely supported this idea! :heart:
Community
Would you like to ask questions and talk to more Brook users?
Join us to the official group at Telegram and be welcome! :slightly_smiling_face:
Support
This project values being simple, direct and self-explanatory. However, if you need some help to integrate Brook to your application, we have the option of a paid consulting service. Contact us!
Projects using Brook
- Brook Telegram - Telegram plugin for Brook framework. [MIT]
- Aproveita.App - PWA application for supermarket products sales. [Comercial]
- Client Web Portal - Application to manage appointments, update demographics, download previous invoices from the RUBI medical records system. [Commercial]
Would you like to add your project to that list above? Feel free to open a new issue requesting it! :-)
Licensing
Brook framework is released under GNU Lesser General Public License v2.1. Check the LICENSE file for more details.