Farseer

Hex.pm Travis (.com) Hexdocs

A configurable Elixir API gateway.

Getting started

Install with:

mix archive.install hex farseer

Check the installation with:

farseer version

Create a farseer.yml file with:

farseer example

Run the example with:

farseer run --port 8000

Quickstart

Simple configuration:

farseer: "0.5.1"
endpoints:
  /test:
    methods:
      - get
      - post
    to: "https://internalservice:3000"
  /login:
    methods:
      - post
  to: "https://loginservice"

Specifying an handler:

/upload:
  methods:
    - get
  handler: Json
  response:
    message: "hello world"

Transformations:

/login:
  methods:
    - post:
        request:
          body:
            - extra_field: "value" # adds a field to the request body
    - patch:
        request:
          headers:
            add:
              - Bearer: "$TOKEN" # adds an header to the request using an env var
  to: "https://example.com"
  transform:
    data:
      items: body.object # returns body.objects instead of body.items
    headers:
      delete:
        - X-service-header
      add:
        - X-awesome-header: "value"

Error handling:

/login:
  methods:
    - post
  to: https://loginservice
  errors:
    - 500: 401 # transform 500 in 401
    - 414: # transform 414 in 401, with custom message
      status: 401
      message: "teapots are not welcome!"
    - any: 401 # transform any error in a 401