diff --git a/Main.lean b/Main.lean index c79f999..623657a 100644 --- a/Main.lean +++ b/Main.lean @@ -11,7 +11,7 @@ open Rinha.Environment /-- Rinha de backend basic application monad -/ -def app (db: Pgsql.Connection) : Ash.App Unit := do +def app (env: Environment) (db: Pgsql.Connection) : Ash.App Unit := do post "/pessoas" $ λ conn => do let person : Option Person := conn.json match person with @@ -19,7 +19,9 @@ def app (db: Pgsql.Connection) : Ash.App Unit := do | some person => let res ← person.create! db match res with - | some person => conn.created person + | some person => do + let location := s!"http://{env.host}:{env.port}/pessoas/{person.id}" + conn.created person location | none => conn.unprocessableEntity "Already exists." get "/pessoas/:id" $ λ conn => do @@ -49,7 +51,7 @@ def main : IO Unit := do -- Connects to the database using the environment variables. let conn ← Pgsql.connect $ env.postgres.toConnectionString - let app := app conn + let app := app env conn IO.println s!"INFO: Database connection set up" -- Run the application with the environment variables host and port. diff --git a/lake-manifest.json b/lake-manifest.json index 642facd..3964881 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -34,6 +34,6 @@ {"git": {"url": "https://github.com/algebraic-sofia/ash.git", "subDir?": null, - "rev": "b771f1bae9301e6131e9b08b039787f6c97db043", + "rev": "236b99b537f8b9d36b37b647f1b9827631335013", "name": "ash", "inputRev?": null}}]}