https support

redirect support

http headers in response

we will have an own logo soon...

New project

git clone https://github.com/0xAX/weber.git

mix weber.new /home/user/SimpleChat

mix deps.get && mix compile

./start.sh

Routing

/ - for login page;

/join/:username - join to the chat room;

/chat/:username - render chat room page.

Views and Controllers

login.html - simple template for login

chat.html - main chat's view

websocket.onopen

websocket.onmessage

websocket.onclose

websocket_init - new websocket connection

websocket_terminate - websocket connection is terminate

websocket_message - handles incoming messages.

Links

Сontinue to develop Weber , and now it has more features than Weber-0.0.1, like:And of course main feature for this moment issupport, which i added yesterday. Time to look at some examples. As i said we have WebSocket support now in Weber, let's write simple web chat application.First of all we must to create new Weber project. Get Weber from github:Go to the Weber's root directory and create new project with:Weber creates project directory with initial project template for our chat. Go to thedirectory and execute following commands for getting dependencies and compiling chat application:You can run empty weber project after successful compilation with executing:and open it with browser atNow we can start to develop our chat application.First of all we must to declare routing for our chat application. It will be three route path:like this:We will have 2 views for chat application:login.html:Here is the simple html template with one input and button elements. I'm using Bootstrap and AngularJS for building my frontend code, but you can use any frontend libraries which you likes for building your applications. As i said here is very simple html template with one input and one button. Button hasevent handler. When user presses on login button, sends AJAX post requests to the controller with user's username:Unfortunatelly now we have now sessions support in Weber, it will be in next versions, so here is very primitive authorization, we save it in gen_server process state. After successful login we redirect to the chat.html page. Chat's template is:Here is the simple chat template with textarea element, and panel with input and button for sending chat message. We control it within frontend:Here we can see that after controller's initialization, it opens WebSocket connection with 3 callbacks:We do nothing when WebSocket's connection is open. If connection close we redirect to the. If we receive message we parse message body and message author and add it to the chat area. Let's see how to handle websocket connection at the backend part. Every Weber's websocket controller must have 3 callbacks:Websocket conrtoller for our chat:Here you can see 3 calbacks which i described above. Every callback takesparameter, which is pid of current websocket connection, andtakesand. And 3calls to the our mock gen_server, for adding new user, removing new user and sending message to the all users. Here is the implementation of this gen_server:That's all. Now you can compile chat application withand launch it with. Full source code of chat example you can find - SimpleChat . Weber now is only at the start of developing and we have many plans: adding session API, html generators, helpers and many many more. If you will have any questions, suggestions or you want to take part in Weber developing write us to the Weber issues at Github.