Teapot and POST:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Teapot and POST:

horrido
I'm trying to learn how to use Teapot. The documentation is pretty clear about how to do GET: but it's thoroughly useless about how to do POST:. Is there any example for how to do POST:?
Reply | Threaded
Open this post in threaded view
|

Re: Teapot and POST:

Attila Magyar
It's basically the same as GET and the others. The request object contains the url encoded form data or whatever was posted. The request object is the same as ZnRequest with a few additional methods. There is a generic at: method that can be used to access both path and queryOrFormParams.

Teapot on
	GET: 'login' -> 
		'<form method="POST">
  				User name:<br>
  				<input type="text" name="user"><br>
  				Password:<br>
  				<input type="password" name="pwd"><br>
				<input type="submit" value="Submit">
			</form>';
	POST: '/login'-> [ :req | 'Welcome ', (req at: #user) ];
	start.
Reply | Threaded
Open this post in threaded view
|

Re: Teapot and POST:

horrido
Thank you very much! Now, I understand. However, it's not that obvious. Your excellent POST: example really should be in the documentation.

Attila Magyar wrote
It's basically the same as GET and the others. The request object contains the url encoded form data or whatever was posted. The request object is the same as ZnRequest with a few additional methods. There is a generic at: method that can be used to access both path and queryOrFormParams.

Teapot on
	GET: 'login' -> 
		'<form method="POST">
  				User name:<br>
  				<input type="text" name="user"><br>
  				Password:<br>
  				<input type="password" name="pwd"><br>
				<input type="submit" value="Submit">
			</form>';
	POST: '/login'-> [ :req | 'Welcome ', (req at: #user) ];
	start.
Reply | Threaded
Open this post in threaded view
|

Re: Teapot and POST:

Attila Magyar
I added it to the doc.
Reply | Threaded
Open this post in threaded view
|

Re: Teapot and POST:

Stephane Ducasse-3
Hi attila

did you do a pull request on the book chapter?

Stef

On Fri, Jun 16, 2017 at 9:16 PM, Attila Magyar <[hidden email]> wrote:
> I added it to the doc.
>
>
>
> --
> View this message in context: http://forum.world.st/Teapot-and-POST-tp4951616p4951702.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: Teapot and POST:

Attila Magyar
Hi Stef,

Yeah, I've just sent a pull request.

Attila
Reply | Threaded
Open this post in threaded view
|

Re: Teapot and POST:

Stephane Ducasse-3
super cool!

On Sun, Jun 25, 2017 at 7:35 PM, Attila Magyar <[hidden email]> wrote:

> Hi Stef,
>
> Yeah, I've just sent a pull request.
>
> Attila
>
>
>
> --
> View this message in context: http://forum.world.st/Teapot-and-POST-tp4951616p4952553.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>