-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenAPI (#251): fetch file, parse schema
- Loading branch information
1 parent
acbb52c
commit b5412e8
Showing
4 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
module Pinafore.WebAPI.Fetch where | ||
|
||
import Network.URI | ||
import Shapes | ||
|
||
fetch :: Text -> IO LazyByteString | ||
fetch t = | ||
case parseURIReference $ unpack t of | ||
Just uri -> | ||
case uriScheme uri of | ||
"file" -> readFile $ uriPath uri | ||
s -> fail $ "URI schema " <> show s <> " not supported" | ||
Nothing -> fail $ show (unpack t) <> " is not a URI" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters