handler.nim
author Mahlon E. Smith <mahlon@martini.nu>
Wed, 27 Oct 2021 13:57:16 -0700
changeset 6 d49437ff8f2f
parent 4 ffb8b9920057
permissions -rw-r--r--
Updates for more recent (v1.6.0) nim.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     1
4
ffb8b9920057 Re-arrange for use with nimble, updates for nim 0.19.
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     2
import src/mongrel2
0
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     3
4
ffb8b9920057 Re-arrange for use with nimble, updates for nim 0.19.
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     4
let handler = newM2Handler( "mlist", "tcp://127.0.0.1:9019", "tcp://127.0.0.1:9018" )
0
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     5
4
ffb8b9920057 Re-arrange for use with nimble, updates for nim 0.19.
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     6
proc woo( request: M2Request ): M2Response =
0
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     7
    var response = request.response
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     8
4
ffb8b9920057 Re-arrange for use with nimble, updates for nim 0.19.
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     9
    response[ "Content-Type" ] = "text/plain"
ffb8b9920057 Re-arrange for use with nimble, updates for nim 0.19.
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    10
    response.body   = "Hi there."
ffb8b9920057 Re-arrange for use with nimble, updates for nim 0.19.
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    11
    response.status = HTTP_OK
0
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    12
    return response
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    13
4
ffb8b9920057 Re-arrange for use with nimble, updates for nim 0.19.
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    14
# handler.action = woo
0
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    15
handler.run
f480e159f575 Initial commit.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    16