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