Skip to content

Latest commit

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

rondo_server Build StatusHex.pmHex.pm

Usir server for rondo applications

Installation

Rondo.Server is available in Hex and can be installed as:

  1. Add rondo_server to your list of dependencies in mix.exs:
defdepsdo[{:rondo_server,"~> 0.1.0"}]end

Usage

Start by creating the rondo component we want to render:

defmoduleMyApp.HellodouseRondo.Componentdefrender(%{"name"=>name})doel("Text",nil,[name])endend

Next define a handler.

defmoduleMyApp.HandlerdouseRondo.Server# The setup method is called for every connection.# The return value is the options to be fed to application initializationdefsetup(_opts,_protocol_info)do{:ok,%{}}end# Called per app. Returns the store and internal statedefinit(app_opts)do{:ok,Rondo.Test.Store.init(%{}),app_opts}end# Here we define how the usir paths route to rondo componentsdefroute("/"=_path,props,_state)do{:ok,el(MyApp.Hello,props)}enddefroute(_,_,_)do{:error,:not_found}end# This method handles authentication. In this example we won't set it up.defauthenticate(_method,_token,_state)do:errorendend

Now we can create an acceptor from the handler and start a usir transport:

acceptor=Rondo.Server.acceptor(MyApp.Handler,%{})Usir.Transport.HTTP.Server.http(acceptor)

Now mount the application at / with a usir client and we're in business.

About

Usir server for rondo applications

Resources

Stars

1 star

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages