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.4.1"
endpoints:
    /test:
        methods:
            - get
            - post
        to: "https://internalservice:3000"
    /login:
        methods:
            - post
        to: "https://loginservice"

Specifying an handler:

/upload:
    methods:
        - post
    handler: "Farseer.Handlers.S3"

Transformations:

/login:
    methods:
        - post:
            request:
                body:
                    - extra_field: "value" # adds a field to the request body
        - patch:
            request:
                headers:
                    add:
                        - Bearer: "my token" # adds an header to the request
    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