- Weber:
- MVC Web framework for Elixir language
- Flexible routing
- Websocket support
- Sessions
- Grunt integration
- Html Helpers
- And many more...
There are some simple steps for running weber based application:
Weber's configuration is in config.ex configuration file
There are the following configuration parameters:
If you need to access to the configuration, you can get it with Config.config
When you've created a new Weber web application, you will have a route.ex file in the /home/user/testWeberApplication/lib directory. This is the app's routing declaration.
It consists of a route macro whose value is a chain of functions with 3 parameters:
Http method can be:
Weber.Route API:
All weber's controllers are in the /project/lib/controllers directory. They can be in any sub-directories.
All weber's controllers must use Weber.Controller
All weber's controllers have an action, which are usually Elixir functions that take two parameters. They are executed when new requests are routed to them.
Action parameter:
Responses
Render views with bindings
Or:Render inline template
Render any view in controller.
File
JSON
Redirect
Plain text
Nothing
Weber uses EEx templates for views. It's just html code with embedded Elixir code. There are the following types of tags:
Weber uses the Ecto library for building data models. Weber's model is a just Elixir an module which uses Ecto API and is located in your_project_name/lib/models directory.
Weber's session manager is automatically started with any web application. Weber has simple API for managing sessions:
Weber's sessions backend:
There are many helpers in Weber which can help you to develop your web application:
Html helpers
Resource helpers
include_view helpers
Weber has WebSockets support and you can handle websocket connection and incoming/outgoing websocket messages in your actions. First of all you need to designate websocket controller in your config.ex file in webserver: section, like:
ws_mod: :Simplechat.Main.Chat
After that you must implement three callbacks:
Note that all websocket connections must start with prefix /_ws/.