Skip to content

Conversation

@carlosdagos
Copy link
Contributor

Description of the change

The previous way was only handling the case where the metadata fetched
could not be correctly parsed. Now it will also disable the global
cache if the HTTP request fails for any reason.

NOTE

I don't know if I'm on to the right thing here. In my build environment
the metadata URL isn't reachable due to firewalls (and I can't change that
in the short term, unfortunately). Maybe this isn't the right change and
I should open an issue to track all issues related to my use case 😄

Thanks for spago! I'm really enjoying using it 👍

Checklist:

  • Added the change to the "Unreleased" section of the changelog
  • Added some example of the new feature to the README
  • Added a test for the contribution (if applicable)

P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊

@carlosdagos carlosdagos force-pushed the topic/http-exception branch from 07458d7 to 87ef717 Compare July 15, 2019 23:51
Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @carlosdagos, thanks for this! Looks good already, I just left a comment in case you'd wish to use the metadata too 🙂

pure meta
pure mempty)
(do
metaBS <- Http.getResponseBody `fmap` Http.httpBS metaURL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like to be able to customize the location of the metadata (because e.g. you have a proxy to GitHub in your network, or you could download it locally, etc) we could try to read it from environment, e.g. something like:

Suggested change
metaBS <- Http.getResponseBody `fmap` Http.httpBS metaURL
metaBS <- Dhall.input Dhall.lazyText ("env:SPAGO_METADATA_JSON ? " <> metaURL <> " as Text")

This won't compile because types mismatch but just to give you an idea. This Dhall string:

  • tries to read the SPAGO_METADATA_JSON variable from environment
  • if that's missing, it tries to import the default URL as Text
  • imports the result as a lazy Text, so then we can parse it

When setting the SPAGO_METADATA_JSON variable, you could put there something like https://some.proxy/metadata.json as Text or ./local/metadata.json as Text or even "{ \"some\": \"escaped json\" }"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this idea. Will experiment with it a bit 👍

The previous way was only handling the case where the metadata fetched
could not be correctly parsed. Now it will also disable the global
cache if the HTTP request fails for any reason.
@carlosdagos carlosdagos force-pushed the topic/http-exception branch from 4fb9a19 to cc04d53 Compare July 16, 2019 22:30
@f-f
Copy link
Member

f-f commented Jul 19, 2019

@carlosdagos I'll merge this before it gets too out of sync with master, feel free to open another PR to add support for overriding the metadata URL 🙂

Thank you!

@f-f f-f merged commit 70d5d5c into purescript:master Jul 19, 2019
@carlosdagos carlosdagos deleted the topic/http-exception branch July 21, 2019 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants