Skip to content

imhassane/elixir-plug-rest-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elixir Plug Boilerplate

This is a basic boilerplate for building rest applications with Elixir/Plug

Installation

To install it, you need to clone this repository or download it.

  1. Make sure you have elixir installed
  2. Run the command below
    git clone --depth=1 https://github.com/imhassane/elixir-plug-rest-boilerplate.git <YOUR_PROJECT_NAME>

The project has already some dependencies required by default.
The mix.exs file dependencies looks like this:

def deps do
  [
    {:plug_cowboy, "~> 2.0"},
    {:jason, "~> 1.2"}
  ]
end

Configuration

All the configurations required can be changed in the config directory depending on the environment.
For the routes and Plug configuration, you can edit the lib/routes/base.ex file. This file is responsible for returning responses in the correct format and status.
By default, you can send response either with standard http codes such as 200 or 404 or you can use atoms defined in the same file such :not_found which will be converted to 404 or :ok which will be converted to 200.

Tutorial: Building a movie api with the boilerplate

I've written a story on medium on how to build and test an api with the boilerplate. See the full article here

About

A boilerplate for building applications with Elixir/Plug

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages