FlEx it's a micro-framework for backend inspired by the simplicity of Flask and the complication to use Phoenix in very small applications
One of the cores of this micro-framework it's be flexible, you can define your whole app in a single file or split in a lot of more files, basic rules, nothing to be followed
This project doesn't pretend to replace Phoenix, the opposite we LOVE Phoenix and we're taking a lot of inspiration on the use and implementation of Phoenix, but sometimes a lot of stuff it's too overkill for some very small servers and more when you want to create a very small service
The design it's based on Plug so it's FULLY COMPATIBLE WITH ALL THE PLUGS! and you can create your own plugs in the same format and the same way to use, 100% compatibility
Also includes some useful plugs to create/configure your server quickly
All the concepts are just described, the examples are in the guides and the module docs
The main piece it's the server
, that contains the routes and the functions and this can be created using the module
FlEx.Server
and this contains all the core to handle routes
Also it's not recommended have all in a single file so to divide the problem usin the routers, that can be created using
the module FlEx.Router
and this can handle in the same way the routes, actually, FlEx.Server
it's a router itself
In the router you can define scopes of route, this will add the scoped route to the defined inner route as a prefix of
the route, so if you have /some/route
with the scope /api/v1
the final route will be /api/v1/some/route
and all
the defined routes in the scope will have the same route prefix
The router can define plugs, and this will be added to the execution of every route, also you can define exclusive plugs in the scope and another exclusive plugs in every router
Defining a route include the route and the function to call when the route it's called, and this function can be defined in the same router, or an external module, the concept says that must be named "controller" and it is, but this library doesn't need implement a specific module for controllers, so you can just create your function in your module and just receive 2 parameters in the function (the connection and the parameters)
If available in Hex, the package can be installed
by adding fl_ex
to your list of dependencies in mix.exs
:
def deps do
[
{:fl_ex, "~> 0.1.3"}
]
end
This project includes a complete implementation example (server, routers, testing), just check the folder fl_ex_example
- Server
- Separated routers
- Https
- Live code changes
- Render
- JSON
- HTML
- Compatible with Plugs (100%)
- Plugs for whole router
- Plugs exclusive for
scope
-
pipeline
to create plug flows and refeer toscope
or route - Private plugs for specific routes
- Testing
- Basic json testing
- More helpers