diff options
author | Loïc Hoguin <[email protected]> | 2016-08-29 12:39:49 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2016-08-29 12:40:03 +0200 |
commit | c807880f7ac73f813b2660ea81a00f7712a4e793 (patch) | |
tree | ba1d09e9b177f230665a80513b33fbd532000ce4 /_build/static/archives/extend/2013-May/000144.html | |
parent | b1df25a7d9cda697513650659b781b55b40898f8 (diff) | |
download | ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.gz ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.bz2 ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.zip |
Add old mailing list archives
Diffstat (limited to '_build/static/archives/extend/2013-May/000144.html')
-rw-r--r-- | _build/static/archives/extend/2013-May/000144.html | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/_build/static/archives/extend/2013-May/000144.html b/_build/static/archives/extend/2013-May/000144.html new file mode 100644 index 00000000..bab09432 --- /dev/null +++ b/_build/static/archives/extend/2013-May/000144.html @@ -0,0 +1,120 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<HTML> + <HEAD> + <TITLE> [99s-extend] question to rest handler + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20question%20to%20rest%20handler&In-Reply-To=%3C519657B3.1080104%40ninenines.eu%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <style type="text/css"> + pre { + white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */ + } + </style> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="000143.html"> + <LINK REL="Next" HREF="000145.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[99s-extend] question to rest handler</H1> + <B>Loïc Hoguin</B> + <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20question%20to%20rest%20handler&In-Reply-To=%3C519657B3.1080104%40ninenines.eu%3E" + TITLE="[99s-extend] question to rest handler">essen at ninenines.eu + </A><BR> + <I>Fri May 17 18:15:47 CEST 2013</I> + <P><UL> + <LI>Previous message: <A HREF="000143.html">[99s-extend] question to rest handler +</A></li> + <LI>Next message: <A HREF="000145.html">[99s-extend] Cowboy Middleware and websockets +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#144">[ date ]</a> + <a href="thread.html#144">[ thread ]</a> + <a href="subject.html#144">[ subject ]</a> + <a href="author.html#144">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>All the callbacks are explained in +<A HREF="http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_rest">http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_rest</A> + +In your case take a special look at content_types_accepted. + +On 05/17/2013 05:41 PM, Witali Monastyrjow wrote: +><i> Hi all, +</I>><i> +</I>><i> I am learning cowboy by building a small application with rest interface. +</I>><i> I have a hello_world rest handler and I want to implement POST method +</I>><i> that returns +</I>><i> json as response to a client. Therefor I implemented callbacks +</I>><i> allowed_methods, +</I>><i> content_types_accepted and hello_json. The docu says user callbacks can +</I>><i> return {Value, Req, State} and also can return {halt, Req, State}. It is +</I>><i> not really clear +</I>><i> what that Value should be. So I tried {ok, Req, State} and {true, Req, +</I>><i> State} and with +</I>><i> both values I have +</I>><i> +</I>><i> =ERROR REPORT==== 11-May-2013::16:06:40 === +</I>><i> Error in process <0.6649.0> with exit value: +</I>><i> {function_clause,[{cowboy_req,reply,[303,.... +</I>><i> +</I>><i> and client gets right response. If I use {halt, Req, State} the client +</I>><i> gets right response too +</I>><i> and there is no errors. So, Is it right way to write a POST callback and +</I>><i> what Values can +</I>><i> be used for user callbacks? I write my code below. +</I>><i> +</I>><i> amike, +</I>><i> Vitali +</I>><i> +</I>><i> allowed_methods(Req, State) -> +</I>><i> {[<<"POST">>, <<"DELETE">>], Req, State}. +</I>><i> +</I>><i> content_types_accepted(Req, State) -> +</I>><i> {[ +</I>><i> {{<<"application">>, <<"x-www-form-urlencoded">>, []}, hello_json} +</I>><i> ], Req, State}. +</I>><i> +</I>><i> hello_json(Req, State) -> +</I>><i> {ok, Req2} = cowboy_req:reply(200, [{<<"content-type">>, +</I>><i> <<"application/json">>} ], <<"{\"rest\": \"Hello World!\"}">>, Req), +</I>><i> {halt, Req2, State}. +</I>><i> +</I>><i> +</I>><i> _______________________________________________ +</I>><i> Extend mailing list +</I>><i> <A HREF="https://lists.ninenines.eu/listinfo/extend">Extend at lists.ninenines.eu</A> +</I>><i> <A HREF="http://lists.ninenines.eu:81/listinfo/extend">http://lists.ninenines.eu:81/listinfo/extend</A> +</I>><i> +</I> + +-- +Loïc Hoguin +Erlang Cowboy +Nine Nines +<A HREF="http://ninenines.eu">http://ninenines.eu</A> + +</PRE> + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="000143.html">[99s-extend] question to rest handler +</A></li> + <LI>Next message: <A HREF="000145.html">[99s-extend] Cowboy Middleware and websockets +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#144">[ date ]</a> + <a href="thread.html#144">[ thread ]</a> + <a href="subject.html#144">[ subject ]</a> + <a href="author.html#144">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend +mailing list</a><br> +</body></html> |