1module Network.HTTP2.Server.File where 2 3import System.IO 4 5import Network.HTTP2.Server.API 6 7-- | Position read based on 'Handle'. 8defaultPositionReadMaker :: PositionReadMaker 9defaultPositionReadMaker file = do 10 hdl <- openBinaryFile file ReadMode 11 return (pread hdl, Closer $ hClose hdl) 12 where 13 pread :: Handle -> PositionRead 14 pread hdl off bytes buf = do 15 hSeek hdl AbsoluteSeek $ fromIntegral off 16 fromIntegral <$> (hGetBufSome hdl buf $ fromIntegral bytes) 17