<commit_before>{-# LANGUAGE OverloadedStrings #-}
module Seed.HTTP where

import           Blaze.ByteString.Builder (copyByteString)
import           Data.Aeson (encode, ToJSON)
import           Network.HTTP.Types.Status
import           Network.Wai (Response, responseBuilder)
import qualified Data.ByteString.Lazy as BL

-- | http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1
s200 :: (ToJSON a, Monad m) => a -> m Response
s200 b = return
       $ responseBuilder status200 []
       $ copyByteString $ BL.toStrict $ encode b

-- | http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2
s201 :: (ToJSON a, Monad m) => a -> m Response
s201 b = return
       $ responseBuilder status201 []
       $ copyByteString $ BL.toStrict $ encode b

-- | 400 Bad Request
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1
s400 :: IO Response
s400 = return
     $ responseBuilder status400 [("Content-Type", "text/plain")]
     $ copyByteString "400"

-- | 404 Not Found
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5
s404 :: IO Response
s404 = return
     $ responseBuilder status404 [("Content-Type", "text/plain")]
     $ copyByteString "404"<commit_msg>forgot 500<commit_after>{-# LANGUAGE OverloadedStrings #-}
module Seed.HTTP where

import           Blaze.ByteString.Builder (copyByteString)
import           Data.Aeson (encode, ToJSON)
import           Network.HTTP.Types.Status
import           Network.Wai (Response, responseBuilder)
import qualified Data.ByteString.Lazy as BL

-- | http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1
s200 :: (ToJSON a, Monad m) => a -> m Response
s200 b = return
       $ responseBuilder status200 []
       $ copyByteString $ BL.toStrict $ encode b

-- | http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2
s201 :: (ToJSON a, Monad m) => a -> m Response
s201 b = return
       $ responseBuilder status201 []
       $ copyByteString $ BL.toStrict $ encode b

-- | 400 Bad Request
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1
s400 :: IO Response
s400 = return
     $ responseBuilder status400 [("Content-Type", "text/plain")]
     $ copyByteString "400"

-- | 404 Not Found
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5
s404 :: IO Response
s404 = return
     $ responseBuilder status404 [("Content-Type", "text/plain")]
     $ copyByteString "404"

-- | 500 Internal Server Error
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1
s500 :: IO Response
s500 = return
     $ responseBuilder status500 []
     $ copyByteString ""
{'fraction_non_alphanumeric': 0.1367816091954023, 'fraction_numerical': 0.09425287356321839, 'mean_word_length': 3.0796875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 9, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3248346', 'n_tokens_mistral': 1046, 'n_tokens_neox': 907, 'n_words': 193}