Weber-0.0.2 features

I'm continue to develop Weber, who don't know what is it Weber, can knows from previous posts that Weber is a Rails-like web framework written with Elixir programming language. Some times ago i released Weber with version - 0.0.2 and now it has many new features. Let's see what we have now.

Controllers


Weber controllers now have many different response types:
  • {:render, [project: "simpleTodo"], [{"HttpHeaderName", "HttpHeaderValheaderVal"}]} - Render views with the same name as controller and sends it to response.
  • {:render_inline, "foo <%= bar %>", [bar: "baz"]}, []} - Render inline template.
  • {:file, path, headers} - Send file in response.
  • {:json, [response: "ok"], [{"HttpHeaderName", "HttpHeaderValheaderVal"}]} - Weber convert keyword to json and sends it to response.
  • {:redirect, "/main"} - Redirect to other resource.
  • {:text, data, headers} - Sends plain text.
  • {:nothing, ["Cache-Control", "no-cache"]} - Sends empty response with status 200 and headers.
Also Weber now has API for getting request parameters, you can get body, method, cookie and other request parameters with the Weber.Http.Params API, it's very easy to use:


Routing


There are some new features in routing too... First of all you can declare route as Controller#action, for example:


Now you can pass any parameters to the URL query string and get it's values with the Weber.Http.Params.param/1 function. For example you got request for: /user?name=0xAX, you can get name parameter's value like this:


Helpers


Html Helper


Html helpers gives you opportunity to generate html templates from elixir:

Include view helper


Include view helper helps to include other views inside another.


Resource Helpers


You can include your static resources like javascript, css, favicon or image files with resource helpers:


Session API


If you will get Weber from master branch, there is sessions support there and simple API for managing sessions:
  • get_session() -> [] | [{atom, binary()}]
  • get_session(key :: atom()) -> [] | binary()
  • set_session_val(key :: atom(), val :: binary()) -> :ok

Logo


And the latest good news in this post, we have a logo:

thank you @caiotarifa for this great work.

Conclusion


Yes, Weber now has many new features as Sessions API, Helpers, Json encoding/decoding and etc... We waiting new contributors, you can help Weber to grow via submiting pull request (If you're interesting - Weber Roadmap, help us with translation onto your language (I18n In development), or just set up star at github. . If you will have any questsions/bug reports/suggestions write us to the issues or join to the #WeberMVC at irc.freenode.net.

Comments

Anonymous said…
Is there any reason not to adopt existing Erlang web framework like ChicagoBoss?
0xax said…
Adopt to what? To Elixir? Maybe, but i want to use Elixir as main
0xax said…
I made some benchmarks, ChicagoBoss is already stable project with stable code base and hard to remake something there, see results: https://github.com/0xAX/weber/issues/96