0 | module TyTTP.HTTP.Producer
4 | import TyTTP.HTTP.Protocol
6 | unsafeFromString : String -> Buffer
7 | unsafeFromString str = unsafePerformIO $
do
8 | let size = stringByteLength str
9 | Just buffer <- newBuffer $
cast size
10 | | Nothing => assert_total $
idris_crash "could not create new buffer"
11 | setString buffer 0 str
18 | -> Context me u v h1 s StringHeaders a b
19 | -> m $
Context me u v h1 s StringHeaders a (Publisher IO e Buffer)
20 | sendText str ctx = do
21 | let stream : Publisher IO e Buffer = Stream.singleton $
unsafeFromString str
22 | pure $
{ response.body := stream
23 | , response.headers :=
24 | [ ("Content-Type", "text/plain")
25 | , ("Content-Length", show $
length str)
33 | -> Context me u v h1 s h2 a b
34 | -> m $
Context me u v h1 Status h2 a b
35 | status s ctx = pure $
{ response.status := s } ctx