mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-03 04:40:50 +03:00
Working out the datatypes.
This commit is contained in:
parent
90470dc67d
commit
7dfc6b9c19
26
pkg/hair/lib/Vere.hs
Normal file
26
pkg/hair/lib/Vere.hs
Normal file
@ -0,0 +1,26 @@
|
||||
module Vere where
|
||||
|
||||
import ClassyPrelude
|
||||
import Data.Void
|
||||
import qualified Vere.Http.Server as Server
|
||||
import qualified Vere.Http.Client as Client
|
||||
|
||||
-- +vere -----------------------------------------------------------------------
|
||||
|
||||
data WTFIsThis
|
||||
= WTFIsThis (Maybe Varience) TheActualFuckingThing
|
||||
|
||||
data Varience = Gold | Iron | Lead
|
||||
|
||||
data TheActualFuckingThing
|
||||
= HttpServer Server.Eff
|
||||
| HttpClient Client.Eff
|
||||
| Behn Void
|
||||
| Clay Void
|
||||
| Boat Void
|
||||
| Sync Void
|
||||
| Newt Void
|
||||
| Ames Void
|
||||
| Init Void
|
||||
| Term Void
|
||||
|
37
pkg/hair/lib/Vere/Http.hs
Normal file
37
pkg/hair/lib/Vere/Http.hs
Normal file
@ -0,0 +1,37 @@
|
||||
-- zuse: +http -----------------------------------------------------------------
|
||||
|
||||
module Vere.Http where
|
||||
|
||||
import ClassyPrelude
|
||||
import Data.Noun
|
||||
|
||||
data Header = Header Text Text
|
||||
|
||||
data Method = CONNECT
|
||||
| DELETE
|
||||
| GET
|
||||
| HEAD
|
||||
| OPTIONS
|
||||
| POST
|
||||
| PUT
|
||||
| TRACE
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
data Request = Request
|
||||
{ method :: Method
|
||||
, url :: Text
|
||||
, headerList :: [Header]
|
||||
, body :: Maybe ByteString
|
||||
}
|
||||
|
||||
data ResponseHeader = ResponseHeader
|
||||
{ statusCode :: Integer
|
||||
, headers :: [Header]
|
||||
}
|
||||
|
||||
data Event = Start ResponseHeader (Maybe ByteString) Bool
|
||||
| Continue (Maybe ByteString) Bool
|
||||
| Cancel
|
||||
|
||||
--instance FromNoun Event where
|
||||
-- fromNoun = undefined
|
12
pkg/hair/lib/Vere/Http/Client.hs
Normal file
12
pkg/hair/lib/Vere/Http/Client.hs
Normal file
@ -0,0 +1,12 @@
|
||||
-- +http-client ----------------------------------------------------------------
|
||||
|
||||
module Vere.Http.Client where
|
||||
|
||||
import ClassyPrelude
|
||||
import Vere.Http
|
||||
|
||||
-- | An http client effect is either requesting outbound, or canceling an old
|
||||
-- outbound connection.
|
||||
data Eff
|
||||
= Request Word Request
|
||||
| CancelRequest Word
|
35
pkg/hair/lib/Vere/Http/Server.hs
Normal file
35
pkg/hair/lib/Vere/Http/Server.hs
Normal file
@ -0,0 +1,35 @@
|
||||
-- +http-server ----------------------------------------------------------------
|
||||
|
||||
module Vere.Http.Server where
|
||||
|
||||
import ClassyPrelude
|
||||
import Vere.Http
|
||||
|
||||
type ServerId = Word
|
||||
type ConnectionId = Word
|
||||
type RequestId = Word
|
||||
|
||||
data Eff = Eff ServerId ConnectionId RequestId ServerRequest
|
||||
|
||||
-- | An http server effect is configuration, or it sends an outbound response
|
||||
data ServerRequest
|
||||
= SetConfig Config
|
||||
| Response Event
|
||||
|
||||
data Config = Config
|
||||
{ secure :: Maybe (Key, Cert)
|
||||
, proxy :: Bool
|
||||
, log :: Bool
|
||||
, redirect :: Bool
|
||||
}
|
||||
|
||||
newtype Key = Key Wain
|
||||
newtype Cert = Cert Wain
|
||||
data Wain = Wain [Text]
|
||||
|
||||
data ClientResponse
|
||||
= Progress ResponseHeader Int (Maybe Int) (Maybe ByteString)
|
||||
| Finished ResponseHeader (Maybe MimeData)
|
||||
| Cancel
|
||||
|
||||
data MimeData = MimeData Text ByteString
|
Loading…
Reference in New Issue
Block a user