Put the signature for codecs.
parent
2ad1ede8f1
commit
1457e7bf7c
|
@ -31,46 +31,54 @@ type UserID = Int -- UserID is either a login or an uid number
|
|||
|
||||
{- 0 -}
|
||||
type Login = { token :: String }
|
||||
codecLogin ∷ CA.JsonCodec Login
|
||||
codecLogin = CA.object "Login" (CAR.record { token: CA.string })
|
||||
|
||||
{- 7 -}
|
||||
type Maintenance = { subject :: MaintenanceSubject.MaintenanceSubject, value :: Maybe Int }
|
||||
codecMaintenance ∷ CA.JsonCodec Maintenance
|
||||
codecMaintenance = CA.object "Maintenance" (CAR.record { subject: MaintenanceSubject.codec, value: CAR.optional CA.int })
|
||||
|
||||
{- 9 -}
|
||||
type NewDomain = { domain :: String }
|
||||
codecNewDomain ∷ CA.JsonCodec NewDomain
|
||||
codecNewDomain = CA.object "NewDomain" (CAR.record { domain: CA.string })
|
||||
|
||||
{- 10 -}
|
||||
type AddOrUpdateZone = { zone :: DNSZone.DNSZone }
|
||||
codecAddOrUpdateZone ∷ CA.JsonCodec AddOrUpdateZone
|
||||
codecAddOrUpdateZone = CA.object "AddOrUpdateZone" (CAR.record { zone: DNSZone.codec })
|
||||
|
||||
{- 11 -}
|
||||
type DeleteZone = { domain :: String }
|
||||
codecDeleteZone ∷ CA.JsonCodec DeleteZone
|
||||
codecDeleteZone = CA.object "DeleteZone" (CAR.record { domain: CA.string })
|
||||
|
||||
{- 12 -}
|
||||
type GetZone = { domain :: String }
|
||||
codecGetZone ∷ CA.JsonCodec GetZone
|
||||
codecGetZone = CA.object "GetZone" (CAR.record { domain: CA.string })
|
||||
|
||||
{- 13 -}
|
||||
type UserDomains = {}
|
||||
codecUserDomains ∷ CA.JsonCodec UserDomains
|
||||
codecUserDomains = CA.object "UserDomains" (CAR.record {})
|
||||
|
||||
{- 14 -}
|
||||
type AddRR = { domain :: String, rr :: ResourceRecord.ResourceRecord }
|
||||
codecAddRR ∷ CA.JsonCodec AddRR
|
||||
codecAddRR = CA.object "AddRR" (CAR.record { domain: CA.string, rr: ResourceRecord.codec })
|
||||
|
||||
{- 15 -}
|
||||
type UpdateRR = { domain :: String, rr :: ResourceRecord.ResourceRecord }
|
||||
codecUpdateRR ∷ CA.JsonCodec UpdateRR
|
||||
codecUpdateRR = CA.object "UpdateRR" (CAR.record { domain: CA.string, rr: ResourceRecord.codec })
|
||||
|
||||
{- 16 -}
|
||||
type DeleteRR = { domain :: String, rrid :: Int }
|
||||
codecDeleteRR ∷ CA.JsonCodec DeleteRR
|
||||
codecDeleteRR = CA.object "DeleteRR" (CAR.record { domain: CA.string, rrid: CA.int })
|
||||
|
||||
|
||||
|
||||
{-
|
||||
RESPONSES
|
||||
-}
|
||||
|
@ -175,9 +183,9 @@ encode m = case m of
|
|||
(MkAddRR request) -> get_tuple 14 codecAddRR request
|
||||
(MkUpdateRR request) -> get_tuple 15 codecUpdateRR request
|
||||
(MkDeleteRR request) -> get_tuple 16 codecDeleteRR request
|
||||
where
|
||||
get_tuple :: forall a. Int -> CA.JsonCodec a -> a -> Tuple UInt String
|
||||
get_tuple num codec request = Tuple (fromInt num) (J.stringify $ CA.encode codec request)
|
||||
where
|
||||
get_tuple :: forall a. Int -> CA.JsonCodec a -> a -> Tuple UInt String
|
||||
get_tuple num codec request = Tuple (fromInt num) (J.stringify $ CA.encode codec request)
|
||||
|
||||
data DecodeError
|
||||
= JSONERROR String
|
||||
|
|
Loading…
Reference in New Issue