equal
deleted
inserted
replaced
30 import Control.Monad |
30 import Control.Monad |
31 import qualified Data.ByteString.Lazy as BL |
31 import qualified Data.ByteString.Lazy as BL |
32 import qualified Data.ByteString.Char8 as B |
32 import qualified Data.ByteString.Char8 as B |
33 import qualified Data.ByteString.UTF8 as UTF8 |
33 import qualified Data.ByteString.UTF8 as UTF8 |
34 import Data.Maybe |
34 import Data.Maybe |
|
35 import qualified Data.Aeson.Types as Aeson |
|
36 import qualified Data.Text as Text |
35 ------------------------------------------------- |
37 ------------------------------------------------- |
36 import CoreTypes |
38 import CoreTypes |
37 |
39 |
38 |
40 |
39 sockAddr2String :: SockAddr -> IO B.ByteString |
41 sockAddr2String :: SockAddr -> IO B.ByteString |
251 sc c | isAlphaNum c = c |
253 sc c | isAlphaNum c = c |
252 | otherwise = '_' |
254 | otherwise = '_' |
253 |
255 |
254 isRegistered :: ClientInfo -> Bool |
256 isRegistered :: ClientInfo -> Bool |
255 isRegistered = (<) 0 . B.length . webPassword |
257 isRegistered = (<) 0 . B.length . webPassword |
|
258 |
|
259 instance Aeson.ToJSON B.ByteString where |
|
260 toJSON = Aeson.toJSON . B.unpack |
|
261 |
|
262 instance Aeson.FromJSON B.ByteString where |
|
263 parseJSON = Aeson.withText "ByteString" $ pure . B.pack . Text.unpack |
|
264 |
|
265 instance Aeson.ToJSONKey B.ByteString where |
|
266 toJSONKey = Aeson.toJSONKeyText (Text.pack . B.unpack) |
|
267 |
|
268 instance Aeson.FromJSONKey B.ByteString where |
|
269 fromJSONKey = Aeson.FromJSONKeyTextParser (return . B.pack . Text.unpack) |
|
270 |