summaryrefslogtreecommitdiff
path: root/app/neyre.hoon
blob: e8f2c17ea898af10e01ca8f9049dbb432893ec30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/-  *neyre, coki
/+  dbug, cokil=coki
/=  router  /web/router
=|  sessions:coki
=*  sessions  -
=|  versioned-state
=*  state  -
%-  agent:dbug
^-  agent:gall
|_  =bowl:gall
+*  this  .
    cokilib  ~(. cokil [sessions bowl])
++  on-init
  ^-  (quip card:agent:gall agent:gall)
  :_  this
    =/  weblib  router(bowl bowl)
    =/  weblib2  weblib(base-path /)
    :~  (eyre-binding-card:weblib2 /)
        (eyre-binding-card:weblib2 /[dap.bowl])
    ==
::
++  on-save
  ^-  vase
  !>(state)
::
++  on-load
  |~  old-state=vase
  ^-  (quip card:agent:gall agent:gall)
  =/  vs  !<(versioned-state old-state)
  ~&  vs=vs
  =.  state
  ?-  -.vs 
    %0  vs
  ==
  `this
::
++  on-poke
  |=  [=mark =vase]
  ^-  (quip card:agent:gall agent:gall)
  ?+  mark  `this
    %coki  =^  cards  sessions  (handle-self-poke:cokilib !<(self-poke:coki vase))
              [cards this]
    %handle-http-request
      ~&  "handling http"
      =/  order  !<([id=@ta req=inbound-request:eyre] vase)
      =/  weblib  ~(. router [bowl id.order req.order state sessions])
      =/  weblib2  weblib(base-path /)
      :-  route:weblib2  this
    %noun  ~&  >  s=sessions  `this
  ==
::
++  on-watch
  |~  path
  ^-  (quip card:agent:gall agent:gall)
  `this
::
++  on-leave
  |~  path
  ^-  (quip card:agent:gall agent:gall)
  `this
::
++  on-peek
  |~  path
  ^-  (unit (unit cage))
  ~
::
++  on-agent
  |~  [wire sign:agent:gall]
  ^-  (quip card:agent:gall agent:gall)
  `this
::
++  on-arvo
  |~  [wire =sign-arvo]
  ^-  (quip card:agent:gall agent:gall)
  `this
::
++  on-fail
  |~  [term tang]
  ^-  (quip card:agent:gall agent:gall)
  `this
--