Uploading a text post
The first thing we want to upload is a text post because it's the simplest type. When we submit the form in HTML, we can specify the form tag enctype attribute as text/plain, application/x-www-form-urlencoded, or multipart/form-data. We already learned how to process application/x-www-form-urlencoded in the Rocket application when we learned how to create a user. We create a struct and derive FromForm for that struct. Later, in the route handling function, we set a route attribute, such as get or post, and assign the struct in the data annotation.
The request body for Content-Type="application/x-www-form-urlencoded" is simple: the form keys and values are encoded in key-value tuples separated by &, with an equals sign (=) between the key and the value. If the characters sent are not alphanumeric, they're percent-encoded (%). An example of a form request body is shown here:
name=John%20Doe&age=18
For uploading a file, Content...