Update the restbuck_client, still work in progress.
Update restbuck_server, remove unused class in inherit. Update libcurl_http_client_request, to parse context headers before the execution. Update wgi_input_stream, commented precondition.
This commit is contained in:
@@ -17,12 +17,26 @@ feature {NONE} -- Initialization
|
||||
local
|
||||
h: LIBCURL_HTTP_CLIENT
|
||||
sess: HTTP_CLIENT_SESSION
|
||||
do
|
||||
create h.make
|
||||
sess := h.new_session ("http://127.0.0.1:8080")
|
||||
-- Create Order
|
||||
create_order (sess)
|
||||
|
||||
-- if id /= Void and then attached sess.get ("/order/" + id, Void) as r then
|
||||
-- print (r.body)
|
||||
-- io.put_new_line
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
create_order (sess: HTTP_CLIENT_SESSION)
|
||||
local
|
||||
s: READABLE_STRING_8
|
||||
j: JSON_PARSER
|
||||
id: detachable STRING
|
||||
context : HTTP_CLIENT_REQUEST_CONTEXT
|
||||
do
|
||||
create h.make
|
||||
sess := h.new_session ("http://127.0.0.1")
|
||||
s := "[
|
||||
{
|
||||
"location":"takeAway",
|
||||
@@ -37,32 +51,25 @@ feature {NONE} -- Initialization
|
||||
}
|
||||
]"
|
||||
|
||||
if attached sess.post ("/order", Void, s) as r then
|
||||
create context.make
|
||||
context.headers.put ("application/json", "Content-Type")
|
||||
if attached sess.post ("/order", context, s) as r then
|
||||
print (r.raw_header)
|
||||
io.put_new_line
|
||||
if attached r.body as m then
|
||||
create j.make_parser (m)
|
||||
|
||||
if j.is_parsed and attached j.parse_object as j_o then
|
||||
if attached {JSON_STRING} j_o.item ("id") as l_id then
|
||||
id := l_id.item
|
||||
end
|
||||
print (m)
|
||||
io.put_new_line
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if id /= Void and then attached sess.get ("/order/" + id, Void) as r then
|
||||
print (r.body)
|
||||
io.put_new_line
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
feature -- Access
|
||||
|
||||
feature -- Change
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ inherit
|
||||
|
||||
URI_TEMPLATE_ROUTED_SERVICE
|
||||
|
||||
ROUTED_SERVICE_HELPER
|
||||
|
||||
DEFAULT_SERVICE
|
||||
|
||||
create
|
||||
|
||||
@@ -167,7 +167,15 @@ feature -- Execution
|
||||
p := curl.slist_append (p, curs.key + ": " + curs.item)
|
||||
end
|
||||
end
|
||||
|
||||
if ctx /= Void then
|
||||
if attached ctx.headers as l_headers_2 then
|
||||
across
|
||||
l_headers_2 as curs_2
|
||||
loop
|
||||
p := curl.slist_append (p, curs_2.key + ": " + curs_2.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
p := curl.slist_append (p, "Expect:")
|
||||
curl_easy.setopt_slist (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_httpheader, p)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ feature -- Input
|
||||
read_string (nb: INTEGER)
|
||||
require
|
||||
is_open_read: is_open_read
|
||||
not_end_of_input: not end_of_input
|
||||
-- not_end_of_input: not end_of_input
|
||||
nb_large_enough: nb > 0
|
||||
deferred
|
||||
ensure
|
||||
|
||||
@@ -17,11 +17,13 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
port_number := 8080
|
||||
base_url := ""
|
||||
|
||||
debug ("nino")
|
||||
print ("Example: start a Nino web server on port " + port_number.out +
|
||||
", %Nand reply Hello World for any request such as http://localhost:" + port_number.out + "/" + base_url + "%N")
|
||||
end
|
||||
create app.make_custom (agent wgi_execute, base_url)
|
||||
app.configuration.set_is_verbose (True)
|
||||
app.listen (port_number)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user