Search code examples
haskellhaskell-snap-framework

snaplet-environment always returning fallback


i have a config similar to:

app
{
 environments
 {
   production
   {
    config-url = "http://www.google.com"
   }
 }
}

and i'm starting my app like

myapp @production

however,

lookupEnvDefault "config-url" "http://www.microsoft.com"

always returns "http://www.microsoft.com"

if i edit the file and take out the production entry then i get the following error:

Given env name: @production wasn't found in your config file.

so it's clearly parsing the config file properly!


Solution

  • WTF. The way I got this to work?

    app
    {
     environments
     {
       production
       {
        config-url = ""
       }
     }
    }
    environments
    {
      production
      {
       config-url = "http://www.google.com"
      }
    }
    

    trace outputs

    http://www.google.com

    if i leave off the app node and descendants or even just the app/environments/production/config-url node then it's unable to find the environment, ie it outputs the following error

    Given env name: @production wasn't found in your config file.

    this has got to be a bug

    update: i submitted this patch https://github.com/statichippo/Snaplet-Environments/tree/patch-1