ode → String → Response String
sendJSON s v = headers reponse
  where reponse = (respond s ∷ Response String) { rspBody = text }
        headers = insertHeader HdrContentLength (show $ length text)
                ∘ insertHeader HdrContentEncoding "UTF-8"
                ∘ insertHeader HdrContentType "application/json"
                ∘ insertHeader (HdrCustom "Access-Control-Allow-Origin") "*"
        text = encodeString v

toSwift = toJSON ∘ checkOrGen

sendJSON ∷ StatusCode → String → Response String
sendJSON s v = headers reponse
  where reponse = (respond s ∷ Response String) { rspBody = text }
        headers = insertHeader HdrContentLength (show $ length text)
                ∘ insertHeader HdrContentEncoding "UTF-8"
                ∘ insertHeader HdrContentType "application/json"
                ∘ insertHeader (HdrCustom "Access-Control-Allow-Origin") "*"
        text = encodeString v
sendJSON s v = headers reponse
  where reponse = (respond s ∷ Response String) { rspBody = text }
        headers = insertHeader HdrContentLength (show $ length text)
                ∘ insertHeader HdrContentEncoding "UTF-8"
                ∘ insertHeader HdrContentType "application/json"
                ∘ insertHeader (HdrCustom "Access-Control-Allow-Origin") "*"
        text = encodeString v