Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an example of a json service #978

Closed
wants to merge 2 commits into from
Closed

Conversation

jberger
Copy link
Member

@jberger jberger commented Jul 1, 2016

Summary

Interestingly, the Request's json method does not appear in any of the guides. This PR adds an example that uses it and other common json service functionality

Motivation

There does appear to be some confusion as to how to get the json representation of a request as evidenced by the google search results for "Mojolicious parse JSON body". Having a small example in the Tutorial seems like a simple place to start. I have chosen to place it after the GET and POST parameters section and the HTTP section since you need the concept of input parameters and also knowledge of the ->req and ->res methods to establish these concepts. The json stash value doesn't seem to be mentioned directly either but is rather introduced obliquely later, this also gives a nod in that direction.

References

https://groups.google.com/forum/#!topic/mojolicious/_r-tzqKKtGI
#522 (comment)


JSON is a very common interchange format for web services. Mojolicious loves
JSON and makes it very easy to both build and use JSON services. In this example
you can fetch module data from L<MetaCPAN|http://metacpan.org>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to write 'In this example we fetch module data from ...'?

@kraih
Copy link
Member

kraih commented Jul 1, 2016

Afraid i have to give this a 👎 , since the example is out of place and introduces features that are meant to be introduced much later in the tutorial.

@dancingfrog
Copy link

dancingfrog commented Jul 1, 2016

Thank you @jberger, I agree that:

  1. Methods that deal with parsing the body of requests (especially JSON) should be thoroughly explained in the current Mojolicious documentation and
  2. Perhaps the example is out of place given the current structure of the tutorial. However, I don't think there's anything sacred about the tutorial or the general flow of the documentation, which I actually find kind of difficult to navigate from the the perspective of a reference guide.

Sorry for the apparent (yet, unintended) "snark" in previous comments.

@jberger
Copy link
Member Author

jberger commented Jul 1, 2016

The tutorial is not intended as a reference guide. Indeed the problem is that the request's json methos is only described in the class reference documentation. I'm trying to correct the fact that it does not appear in the Guides which is where we want people to be introduced to the concepts.

@kraih
Copy link
Member

kraih commented Jul 1, 2016

Closing this pull request for now. While most of us still believe that an example similar to this one should exist in the guides, @dancingfrog's behavior here and on other communication channels has resulted in an exodus of volunteers willing to work on it.

@kraih kraih closed this Jul 1, 2016
@jberger jberger deleted the tutorial_json_service branch July 3, 2016 18:55
@jberger
Copy link
Member Author

jberger commented Jul 3, 2016

For the record, a similar tutorial was added in cebbec8...56bb601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants