Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tsloughter/erlangdc2013

Erlang on Heroku Workshop ErlangDC 2013
https://github.com/tsloughter/erlangdc2013

Last synced: about 1 month ago
JSON representation

Erlang on Heroku Workshop ErlangDC 2013

Awesome Lists containing this project

README

        

Based on
http://boundary.com/blog/2012/09/13/comparing-go-and-java/. See
performance test scripts here https://github.com/patrick-higgins/go-and-java/blob/master/bench.sh

## Local Setup

### Setup Local Database

```
λ sudo -u postgres createdb erlangdc
λ psql erlangdc
=> create table users (
id text not null,
apikey text not null,
name text not null,
email text not null,
password_hash text not null,
admin boolean not null default false,
active boolean not null default true,
created_at timestamp with time zone not null default localtimestamp,
updated_at timestamp with time zone not null default localtimestamp
);
=> insert into users (id, apikey, name, email, password_hash)
values ('1', 'apikey_value', 'John', '[email protected]', 'password_hash_value');
```

### Build and Run

```shell
λ make rel
λ PORT=8080 DATABASE_URL=postgres://:@localhost:5432/erlangdc ./_rel/bin/erlangdc
```

### Send Request

base64 encode the name:apikey value.

```shell
λ curl -H "authorization: Basic Sm9objphcGlrZXlfdmFsdWU=" localhost:8080/user
{"id":"1","email":"[email protected]","created_at":"2012-12-15T16:19:45.618303Z","updated_at":"2012-12-15T16:19:45.618303Z","name":"John","admin":false,"active":true}
```

## Heroku Setup

### Create Heroku App

```shell
λ heroku create --buildpack https://github.com/tsloughter/heroku-buildpack-erlang.git
```

### Setup Database

```shell
λ heroku addons:add heroku-postgresql:dev

λ heroku pg:psql DATABASE_URL
=> create table users (
id text not null,
apikey text not null,
name text not null,
email text not null,
password_hash text not null,
admin boolean not null default false,
active boolean not null default true,
created_at timestamp with time zone not null default localtimestamp,
updated_at timestamp with time zone not null default localtimestamp
);
=> insert into users (id, apikey, name, email, password_hash)
values ('1', 'apikey_value', 'John', '[email protected]', 'password_hash_value');
```

### Push to Heroku

```shell
λ git push heroku master
```