Skip to content
Lightning is an Elixir Web framework for making simple REST API endpoints based on Plug
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lightning
README.md

README.md

Lightning

Lightning is an Elixir framework for making simple REST API endpoints based on Plug

Hex version badge Docs

How to get started:

Create a new file (App.ex)

defmodule App do 
   use Lightning.HTTP
   import Lightning

 #Create a new route endpoint
 #Route: GET "/helloworld/"
 def route("GET", ["helloworld"], conn) do

    #Set additional response information (based on Plug responses)
    conn 
    |> put_resp_header("Hello", "World")
    |> put_resp_content_type("text/html")
    |> put_resp_cookie("abc", "def")
    |> put_status(200)

    #Send a text response with a statuscode of 200:
    text(conn, 200, "Hello world")
   end
end

Running the server

Start up a server using the iex command:

    iex -S mix
    iex> {:ok, _} = Lightning.start(5000, App, :dev)
    

Navigating to localhost:5000/helloworld will output text response:
Hello world

Example Code

code example

You can’t perform that action at this time.