Build Status Coverage Status Version Gitter

Modular web framework for Elixir


Reason for Existence

Why build this when Dynamo, Weber, and Phoenix exist with growing communities? While both projects are great in their own right, Sugar aims to be another contender, sparking more development on all three projects (and/or others that may follow) and giving developers another option when deciding what framework fits their needs best. Sugar may even strive to shake things up just as ChicagoBoss has done.

Getting Started

# Clone this repo
git clone
cd simple

# Get project dependencies
mix deps.get

# Start the web server
mix server # or `iex -S mix server` if you want access to iex


Currently, Sugars expects a Config module to be defined in your project that has a config/0 function defined for configuring your application. A simple Keyword list is returned with the configuration values.

Eventually, this will be replaced with a more elegant solution.

Valid options:


defmodule Config do
  def config do
      log: true,
      server: [
        port: 4000


Because Sugar builds upon Plug, it leverages Plug.Router to do the heavy lifting in routing your application, adding an alternate DSL.

Routes are defined with the form:

method route [guard], controller, action

method is get, post, put, patch, delete, or options, each responsible for a single HTTP method. method can also be any, which will match on all HTTP methods. controller is any valid Elixir module name, and action is any valid function defined in the controller module.


defmodule Router do
  use Sugar.Router

  get "/", Hello, :index
  get "/pages/:id", Hello, :show
  post "/pages", Hello, :create
  put "/pages/:id" when id == 1, Hello, :show


All controller actions should have an arrity of 2, with the first argument being a Plug.Conn representing the current connection and the second argument being a Keyword list of any parameters captured in the route path.

Sugar bundles these response helpers to assist in sending a response:


defmodule Hello do
  use Sugar.Controller

  def index(conn, []) do
    render conn, "index.html.eex", []

  def show(conn, args) do
    render conn, "show.html.eex", args

  def create(conn, []) do
    render conn, "create.html.eex", []

Todo Items

Who's behind this?

Why, the contributors, of course! Would you consider being one? Please send a pull request :)

How to start contributing

The main product of this repository is the example terms in the file This project uses those guidelines as the basis for its own development process. Please refer to that file.


Sugar is released under the MIT License.

See LICENSE for details.