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

docs(ws-tutorial): add a WebSocket tutorial #2245

Merged
merged 19 commits into from
Jul 25, 2024

Conversation

derkweijers
Copy link
Contributor

@derkweijers derkweijers commented Jul 13, 2024

Summary of Changes

Add a tutorial on how to work with websockets in a Falcon app. This is to be read as a quickstart, linking to the reference page for more info.

Related Issues

Closes #2240

Pull Request Checklist

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once; it will save you a few review cycles!

If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
  • Added tests for changed code.
  • Prefixed code comments with GitHub nick and an appropriate prefix.
  • Coding style is consistent with the rest of the framework.
  • Updated documentation for changed code.
    • Added docstrings for any new classes, functions, or modules.
    • Updated docstrings for any modifications to existing code.
    • Updated both WSGI and ASGI docs (where applicable).
    • Added references to new classes, functions, or modules to the relevant RST file under docs/.
    • Updated all relevant supporting documentation files under docs/.
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Changes (and possible deprecations) have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst. (Run towncrier --draft to ensure it renders correctly.)

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

PR template inspired by the attrs project.

derkweijers and others added 2 commits July 13, 2024 15:18
Add a tutorial on how to work with websockets in a Falcon app. This is to be read as a quickstart, linking to the reference page for more info.

falconry#2240
@derkweijers derkweijers changed the title docs(ws-tutorial): add tutorial on how to use websockets docs(ws-tutorial): add a tutorial on how to use websockets Jul 13, 2024
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

I've only skimmed through quickly, and it looks really nice! Thank you!

As discussed in the Sprint room,

  • It would be nice to put at least the final version into a .py file, so we could run linters on it, or maybe even write a couple of simple CI test cases.
  • Passing any headers to a WebSocket connection unfortunately didn't seem to work the last time I checked. We need to check if that has changed, and then maybe offer a different way, because I think people do want to experiment with this in the browser. Maybe it would be also nice to provide a short Javascript Console snippet to connect to our server, and log messages.

docs/user/tutorial-websockets.rst Show resolved Hide resolved
docs/user/tutorial-websockets.rst Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jul 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.17%. Comparing base (89b5fb0) to head (4dcb8a6).

❗ There is a different number of reports uploaded between BASE (89b5fb0) and HEAD (4dcb8a6). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (89b5fb0) HEAD (4dcb8a6)
2 1
Additional details and impacted files
@@             Coverage Diff              @@
##            master    #2245       +/-   ##
============================================
- Coverage   100.00%   36.17%   -63.83%     
============================================
  Files           63       63               
  Lines         6852     6852               
  Branches      1260     1260               
============================================
- Hits          6852     2479     -4373     
- Misses           0     4315     +4315     
- Partials         0       58       +58     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The max width is now set to 80. Not all lines fit, but most do.

falconry#2240
Authentication is now done via the first-message method instead of headers.

falconry#2240
vytas7 and others added 5 commits July 14, 2024 10:56
@derkweijers derkweijers requested a review from vytas7 July 14, 2024 09:02
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

Thank you once again for joining our Sprint, and for this tutorial! 💯
I took the liberty of tweaking some small things to my liking, and I think we can now merge this. I'll file follow-up improvements as new issues.

@vytas7 vytas7 changed the title docs(ws-tutorial): add a tutorial on how to use websockets docs(ws-tutorial): add a WebSocket tutorial Jul 25, 2024
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

Ah, it seems we forgot to commit wslook/.coveragerc. Do you maybe have the file lying anywhere around @derkweijers?

@derkweijers
Copy link
Contributor Author

Ah, it seems we forgot to commit wslook/.coveragerc. Do you maybe have the file lying anywhere around @derkweijers?

Yes! Added it to the repo.

Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

Thanks! 👍

@vytas7 vytas7 merged commit cbca63d into falconry:master Jul 25, 2024
37 of 38 checks passed

Now we can test the application by running the following command::

$ http localhost:8000/hello
Copy link
Member

Choose a reason for hiding this comment

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

we could mention how to install httpie

@CaselIT
Copy link
Member

CaselIT commented Jul 25, 2024

I guess I've arrived too late with the review, @vytas7 you mentioned you wanted to cleanup something else, maybe you can incorporate the suggestions?

@derkweijers thanks for the great tutorial, and for participating in the sprint!

@vytas7
Copy link
Member

vytas7 commented Jul 25, 2024

@CaselIT yeah, thanks! Just add these suggestions to #2255

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

Successfully merging this pull request may close these issues.

Create WebSocket tutorial
3 participants