POST handler.

Exemple of route responding to POST requests.

class PostHandler
    super Handler

    redef fun post(req, res) do res.send "POST request received"
end

Property definitions

popcorn $ Handler :: post
	# POST handler.
	#
	# Exemple of route responding to POST requests.
	# ~~~
	# class PostHandler
	#	super Handler
	#
	#	redef fun post(req, res) do res.send "POST request received"
	# end
	# ~~~
	fun post(req: HttpRequest, res: HttpResponse) do end
lib/popcorn/pop_handlers.nit:137,2--147,53

popcorn $ CounterAPI :: post
	redef fun post(req, res) do
		counter += 1
		res.json(json_counter)
	end
lib/popcorn/examples/angular/example_angular.nit:39,2--42,4

popcorn $ PostHandler :: post
	redef fun post(req, res) do
		var tpl = new Template
		tpl.addn "URI: {req.uri}"
		tpl.addn "Body: {req.body}"
		for name, arg in req.post_args do
			tpl.addn "{name}: {arg}"
		end
        res.send tpl
	end
lib/popcorn/examples/handlers/example_post_handler.nit:25,2--33,4

popcorn $ UserList :: post
	redef fun post(req, res) do
		var json = new JsonObject
		json["login"] = req.post_args["login"]
		json["password"] = req.post_args["password"]
		db.collection("users").insert(json)
		res.redirect("/")
	end
lib/popcorn/examples/mongodb/example_mongodb.nit:54,2--60,4

popcorn $ AppLogin :: post
	redef fun post(req, res) do
		req.session.as(not null).is_logged = true
		res.redirect("/")
	end
lib/popcorn/examples/sessions/example_session.nit:36,2--39,4