Compare commits
No commits in common. "c883efcf41eec9c07d2f82d993a0965e54523b07" and "3441ab2bbb78bb3367411f50c67d27ce0dfc901b" have entirely different histories.
c883efcf41
...
3441ab2bbb
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
result*
|
result
|
||||||
dist/
|
dist/
|
||||||
|
@ -16,7 +16,6 @@ let
|
|||||||
_pkgs.binutils-unwrapped
|
_pkgs.binutils-unwrapped
|
||||||
haskellPackages.ghcid
|
haskellPackages.ghcid
|
||||||
haskellPackages.hasktags
|
haskellPackages.hasktags
|
||||||
haskellPackages.cabal-install
|
|
||||||
(haskellPackages.ghcWithHoogle (_: pkg.buildInputs ++ pkg.propagatedBuildInputs))
|
(haskellPackages.ghcWithHoogle (_: pkg.buildInputs ++ pkg.propagatedBuildInputs))
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
16
src/API.hs
16
src/API.hs
@ -5,16 +5,16 @@
|
|||||||
{-# Language OverloadedStrings #-}
|
{-# Language OverloadedStrings #-}
|
||||||
module API where
|
module API where
|
||||||
|
|
||||||
import Servant.API
|
import Servant.API
|
||||||
import ClassyPrelude
|
import ClassyPrelude
|
||||||
|
|
||||||
import qualified API.IPFS as IPFS
|
import qualified API.IPFS as IPFS
|
||||||
|
|
||||||
import Network.HTTP.Media ((//), (/:))
|
import Text.Pandoc.Readers.Markdown (readMarkdown)
|
||||||
import Text.Pandoc.Class (runPure)
|
import Text.Pandoc.Writers.HTML (writeHtml5String)
|
||||||
import Text.Pandoc.Options (def)
|
import Text.Pandoc.Class (runPure, PandocMonad)
|
||||||
import Text.Pandoc.Readers.Markdown (readMarkdown)
|
import Text.Pandoc.Options (def)
|
||||||
import Text.Pandoc.Writers.HTML (writeHtml5String)
|
import Network.HTTP.Media ((//), (/:))
|
||||||
|
|
||||||
data HTML
|
data HTML
|
||||||
|
|
||||||
@ -31,5 +31,5 @@ instance Accept HTML where
|
|||||||
|
|
||||||
type API = "ipfs" :> IPFS.API
|
type API = "ipfs" :> IPFS.API
|
||||||
|
|
||||||
type DocumentedAPI = "api" :> API
|
type DocumentedAPI = API
|
||||||
:<|> "help" :> Get '[PlainText, HTML] Docs
|
:<|> "help" :> Get '[PlainText, HTML] Docs
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
module Server.IPFS where
|
module Server.IPFS where
|
||||||
|
|
||||||
import API.IPFS
|
import API.IPFS
|
||||||
import ClassyPrelude hiding (hash)
|
|
||||||
import Control.Lens (over, _Left)
|
|
||||||
import Network.DNS
|
|
||||||
import Servant
|
import Servant
|
||||||
|
import ClassyPrelude
|
||||||
|
|
||||||
|
import Network.DNS
|
||||||
|
|
||||||
|
import Control.Lens (over, _Left)
|
||||||
|
|
||||||
handler :: Server API
|
handler :: Server API
|
||||||
handler = liftIO getHash >>= either (const (throwError err500)) return
|
handler = liftIO getHash >>= either (const (throwError err500)) return
|
||||||
@ -21,6 +23,6 @@ handler = liftIO getHash >>= either (const (throwError err500)) return
|
|||||||
-- This is terrible
|
-- This is terrible
|
||||||
return (eTxt >>= maybe (Left "Could not find dnslink") Right . hash)
|
return (eTxt >>= maybe (Left "Could not find dnslink") Right . hash)
|
||||||
hash [x] = case x of
|
hash [x] = case x of
|
||||||
(stripPrefix "dnslink=" -> Just h) -> Just . VersionHash . decodeUtf8 $ h
|
(stripPrefix "dnslink" -> Just h) -> Just . VersionHash . decodeUtf8 $ h
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
hash _ = Nothing
|
hash _ = Nothing
|
||||||
|
Loading…
Reference in New Issue
Block a user