module Bird.Reply.Codes where
import qualified Data.Map as Hash
import Bird.Reply
import Data.Default
ok_ :: Reply
ok_ = def
ok :: String -> IO Reply
ok body = return $ ok_ { replyBody = body }
created_ :: Reply
created_ = def { replyStatus = 201 }
created :: String -> IO Reply
created body = return $ created_ { replyBody = body }
accepted_ :: Reply
accepted_ = def { replyStatus = 202 }
accepted :: String -> IO Reply
accepted body = return $ accepted_ { replyBody = body }
movedPermanently_ :: Reply
movedPermanently_ = def { replyStatus = 301 }
movedPermanently :: String -> IO Reply
movedPermanently url = return $ movedPermanently_ { replyHeaders = Hash.fromList [("Location", url)] }
found_ :: Reply
found_ = def { replyStatus = 302 }
found :: String -> IO Reply
found url = return $ found_ { replyHeaders = Hash.fromList [("Location", url)] }
unauthorized_ :: Reply
unauthorized_ = def { replyStatus = 401, replyBody = "You are not authorized to access this resource."}
unauthorized :: String -> IO Reply
unauthorized body = return $ unauthorized_ { replyBody = body }
forbidden_ :: Reply
forbidden_ = def { replyStatus = 403, replyBody = "You do not have permission to access this resource."}
forbidden :: String -> IO Reply
forbidden body = return $ forbidden_ { replyBody = body }
notFound_ :: Reply
notFound_ = def { replyStatus = 404, replyBody = "404 Not Found" }
notFound :: String -> IO Reply
notFound body = return $ notFound_ { replyBody = body }
gone_ :: Reply
gone_ = def { replyStatus = 410, replyBody = "410 Gone" }
gone :: String -> IO Reply
gone body = return $ gone_ { replyBody = body }
internalServerError_ :: Reply
internalServerError_ = def { replyStatus = 500, replyBody = "Oops... something went wrong." }
internalServerError :: String -> IO Reply
internalServerError body = return $ internalServerError_ { replyBody = body }