Compare commits
No commits in common. "f55a982f57d2955f64c037ebf246496aed53e812" and "83e39cbe6c0dae4ca39e100e0504b7a35fcbf455" have entirely different histories.
f55a982f57
...
83e39cbe6c
@ -102,24 +102,22 @@ instance VersionedCatalog AppM 1 where
|
|||||||
getChannels = getChannelsV1
|
getChannels = getChannelsV1
|
||||||
getBooks = getBooksV1
|
getBooks = getBooksV1
|
||||||
|
|
||||||
relUrl :: Text -> Rel
|
|
||||||
relUrl x = Rel ("/api/current/" <> x)
|
|
||||||
|
|
||||||
getBooksV1 :: Channel.ChannelID -> SafeUser -> AppM (Catalog 1)
|
getBooksV1 :: Channel.ChannelID -> SafeUser -> AppM (Catalog 1)
|
||||||
getBooksV1 identifier SafeUser{} = do
|
getBooksV1 identifier SafeUser{} = do
|
||||||
updated <- liftIO getCurrentTime
|
updated <- liftIO getCurrentTime
|
||||||
let self = relUrl selfUrl
|
let self = Rel ("/api/current" <> selfUrl)
|
||||||
start = relUrl startUrl
|
start = Rel ("/api/current" <> startUrl)
|
||||||
selfUrl = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(ChannelCatalog 1)) identifier
|
selfUrl = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(ChannelCatalog 1)) identifier
|
||||||
startUrl = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(RootCatalog 1))
|
startUrl = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(RootCatalog 1))
|
||||||
entries = mempty
|
entries = mempty
|
||||||
pagination = Pagination Nothing Nothing
|
pagination = Pagination Nothing Nothing
|
||||||
pure CatalogV1{..}
|
pure CatalogV1{..}
|
||||||
|
|
||||||
|
|
||||||
getChannelsV1 :: SafeUser -> AppM (Catalog 1)
|
getChannelsV1 :: SafeUser -> AppM (Catalog 1)
|
||||||
getChannelsV1 SafeUser{username} = do
|
getChannelsV1 SafeUser{username} = do
|
||||||
updated <- liftIO getCurrentTime
|
updated <- liftIO getCurrentTime
|
||||||
let self = relUrl selfUrl
|
let self = Rel ("/api/current/" <> selfUrl)
|
||||||
-- I'm not sure if this safe link approach is really useable with this
|
-- I'm not sure if this safe link approach is really useable with this
|
||||||
-- api hierarchy since I can't access the topmost api from here. Also
|
-- api hierarchy since I can't access the topmost api from here. Also
|
||||||
-- authentication would bring a little bit of extra effort as well
|
-- authentication would bring a little bit of extra effort as well
|
||||||
@ -132,7 +130,7 @@ getChannelsV1 SafeUser{username} = do
|
|||||||
fromChannel :: UTCTime -> Channel.Channel -> Entry 1
|
fromChannel :: UTCTime -> Channel.Channel -> Entry 1
|
||||||
fromChannel updated Channel.Channel{..} =
|
fromChannel updated Channel.Channel{..} =
|
||||||
let url = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(ChannelCatalog 1)) identifier
|
let url = pack . uriPath . linkURI $ safeLink (Proxy @(BaseAPI 1)) (Proxy @(ChannelCatalog 1)) identifier
|
||||||
self = relUrl url
|
self = Rel ("/api/current/" <> url)
|
||||||
in EntryV1 channel channel updated channel (Left $ SubSection self)
|
in EntryV1 channel channel updated channel (Left $ SubSection self)
|
||||||
|
|
||||||
type VersionedAPI (v :: Nat) = Auth '[SA.BasicAuth, SA.JWT] SafeUser :> BaseAPI v
|
type VersionedAPI (v :: Nat) = Auth '[SA.BasicAuth, SA.JWT] SafeUser :> BaseAPI v
|
||||||
|
Loading…
Reference in New Issue
Block a user