Use ffi for config

This commit is contained in:
Sam Dodrill 2015-01-09 19:08:54 -08:00
parent 7d2509e469
commit 830fd195dc
2 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,13 @@
config = require "lapis.config" config = require "lapis.config"
ffi = actualrequire("ffi")
ffi.cdef [[
char *getenv(const char *name)
]]
getenv = (name) ->
ffi.string ffi.C.getenv name
config "development", -> config "development", ->
port 8080 port 8080
@ -15,8 +23,8 @@ config "docker", ->
postgres -> postgres ->
backend "pgmoon" backend "pgmoon"
port os.getenv "POSTGRESQL_PORT_5432_TCP_PORT" port getenv "POSTGRESQL_PORT_5432_TCP_PORT"
host os.getenv "POSTGRESQL_PORT_5432_TCP_ADDR" host getenv "POSTGRESQL_PORT_5432_TCP_ADDR"
user os.getenv "DB_USER" user getenv "DB_USER"
password os.getenv "DB_PASS" password getenv "DB_PASS"
database os.getenv "DB_NAME" database getenv "DB_NAME"

View File

@ -16,6 +16,7 @@ http {
location / { location / {
default_type text/html; default_type text/html;
content_by_lua ' content_by_lua '
actualrequire = require
require = require"require".require require = require"require".require
require("moonscript") require("moonscript")
require("lapis").serve("app") require("lapis").serve("app")