hashes remain text formats
This commit is contained in:
parent
f9a3490da5
commit
aa7d7e55cb
2 changed files with 6 additions and 3 deletions
|
@ -15,6 +15,8 @@ import Data.ByteString.Builder (byteString)
|
||||||
|
|
||||||
import Data.String (fromString)
|
import Data.String (fromString)
|
||||||
|
|
||||||
|
import Data.Text.Encoding (encodeUtf8)
|
||||||
|
|
||||||
import Servant
|
import Servant
|
||||||
|
|
||||||
import Network.Wai
|
import Network.Wai
|
||||||
|
@ -40,7 +42,7 @@ avatarGet aid = do
|
||||||
flush
|
flush
|
||||||
) :: Application)
|
) :: Application)
|
||||||
else
|
else
|
||||||
return ((\_ response -> response $ responseStream status200 [(hETag, BS.pack (avatarHash (head as)))] $
|
return ((\_ response -> response $ responseStream status200 [(hETag, encodeUtf8 (avatarHash (head as)))] $
|
||||||
\write flush -> do
|
\write flush -> do
|
||||||
write $ byteString $ BS.pack $ avatarData $ head as
|
write $ byteString $ BS.pack $ avatarData $ head as
|
||||||
flush
|
flush
|
||||||
|
|
|
@ -5,6 +5,7 @@ module Types.Avatar where
|
||||||
import Data.ByteString
|
import Data.ByteString
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import Data.Text.Encoding (decodeUtf8)
|
||||||
|
|
||||||
import Data.Word (Word8)
|
import Data.Word (Word8)
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ import Classes
|
||||||
data Avatar = Avatar
|
data Avatar = Avatar
|
||||||
{ avatarId :: Int
|
{ avatarId :: Int
|
||||||
, avatarName :: T.Text
|
, avatarName :: T.Text
|
||||||
, avatarHash :: [Word8]
|
, avatarHash :: T.Text
|
||||||
, avatarData :: [Word8]
|
, avatarData :: [Word8]
|
||||||
}
|
}
|
||||||
deriving (Show, Generic)
|
deriving (Show, Generic)
|
||||||
|
@ -32,7 +33,7 @@ instance FromDatabase Avatar where
|
||||||
type OutTuple Avatar = (Int, T.Text, ByteString, ByteString)
|
type OutTuple Avatar = (Int, T.Text, ByteString, ByteString)
|
||||||
|
|
||||||
fromDatabase (id_, name, hash, data_) =
|
fromDatabase (id_, name, hash, data_) =
|
||||||
Avatar id_ name (unpack hash) (unpack data_)
|
Avatar id_ name (decodeUtf8 hash) (unpack data_)
|
||||||
|
|
||||||
|
|
||||||
data AvatarData = AvatarData
|
data AvatarData = AvatarData
|
||||||
|
|
Loading…
Reference in a new issue