Property definitions

app $ MyHttpRequest :: defaultinit
# Simple asynchronous HTTP request to http://example.com/ displaying feedback to the window
class MyHttpRequest
	super AsyncHttpRequest

	# Back reference to the window to show feedback to the user
	var win: HttpRequestClientWindow

	# ---
	# Config the request

	redef fun uri do return "http://example.com/"
	redef fun deserialize_json do return false

	# ---
	# Customize callbacks

	redef fun before
	do
		win.label_response.text = "Sending request..."

		# Disable button to prevent double requests
		win.button_request.enabled = false
	end

	redef fun on_load(data, status)
	do win.label_response.text = "Received response code {status} with {data.as(Text).byte_length} bytes"

	redef fun on_fail(error)
	do win.label_response.text = "Connection error: {error}"

	redef fun after do win.button_request.enabled = true
end
lib/app/examples/http_request_example.nit:27,1--58,3