-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Because Rails' approach to web framework is not all wrong. We aim at providing a similar - although much simpler environment to the developers.
Crails is fast and very light. And it helps you work with the fastest libraries around (for instance, the ODB ORM).
The framework consumes very little memory, and has very efficient response time, when all the unused modules are disabled (which is our default configuration).
The tools available to C++ developers for debugging and profiling will give you a great advantage over other technologies when it comes to optimizing your application.
Crails routes your requests, handles parameters, file uploads, exceptions, and can provide you with a session object.
Crails comes with SSL support, cookie encryption and CSRF tokens.
Crails comes with an asset pipeline, powered by guard. It can crunch together your Javascript, CoffeeScript, TypeScript and SCSS assets, with the ability of minimizing them when you're on production mode.
The crails-front
module also provides an asset pipeline so that you can develop the front-end of your application using C++ code that gets compiled to Javascript or WebASM, using cheerp's technology, thus effectively gaining the ability to share code between frontend and backend.
Crails comes with a docker
module, providing a docker image, compiling all dependencies of Crails over a debian image. It provides a complete environment for compiling and testing crails applications.
The modules are pieces of crails that can be added to your project to bring some commonly needed, but not vital features.
- crails-json and crails-html gives the ability to write HTML and JSON templates in C++
- crails-mail allows you to send mail. In combination with crails-html, you can also send html emails
- crails-image gives you a simple way of storing uploaded images, and can use ImageMagick to generate thumbnails
- crails-cache adds support for libmemcache
- crails-sidekic implements a service to run background tasks on the server
- crails-odb adds support for the ODB ORM (support for SQL databases)
- crails-sentry adds an exception catcher that will log errors to a Sentry instance
- crails-sync provides a pub/sub messaging client, running Faye
- crails-xmlrpc allows your crails server to act as an xmlrpc server, and provide a synchronous xmlrpc client
- crails-proxy allows your crails server to act as a proxy
- crails-front adds support for C++ to Javascript compilation, using cheerp
Crails is built upon the cppnetlib, which is a boost powered library that implements the http server and parser that our framework uses.
Crails uses the cppnetlib to implement the request pipe, a two-step process looping over parsers and handlers, collecting data about the request, data about the response, before letting cppnetlib handle the rest. The following diagram describes this process:
+------------+
| cpp netlib |
| server |
+------------+
|
Exception Catcher ----------------|
| |
| v
v Prepare a 500 response.
Request Parsers cppnetlib sends the response
|
|
v
+--------------+
| Data |
| (cookies, |
|uri parameters| *Request Parsers*
| http headers)| They read data from the http
+--------------+ request, and store them in a
| more accessible fashion.
v
+-----------------+ They run one after the other,
| Multipart | util one of them declares the
|(multipart forms,| parsing over.
| file uploads) |
+-----------------+ Parameters are stored in a
| boost::property_tree::ptree,
v which the developer can then
+------------------+ access in a Controller through
| Form | the `params` attribute.
|(urlencoded forms)|
+------------------+
|
v
+------------------+
| JSON |
|(application/json)|
+------------------+
|
+------------------+
| ... |
| you may add your |
| own parsers |
+------------------+
|
|
Request Handlers
|
|
v
+------------------+ +--------------+ +-----------------+
| Action Handler |------------->| Router |--- route matches --> | Your controller |
+------------------+ +--------------+ +-----------------+
| |
v v
no route match cppnetlib sends the response
|
|--------------------------------|
|
v *File handler*
+------------------+ Though the File handler can
| File Handler | serve your assets, it is not
+------------------+ designed for production. We
| encourage you to use, for
v instance, nginx as a load
+------------------+ balancer and a file server.
| ... |
| you may add your |
| own handlers |
+------------------+
cppnetlib sends
the response