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(htmx): add request_class to example #3725

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yujinyuz
Copy link

@yujinyuz yujinyuz commented Sep 8, 2024

Description

This just adds the request_class into the example provided in the htmx section. I was just following the example and encountered an error.

Closes

#3723

@yujinyuz yujinyuz requested review from a team as code owners September 8, 2024 16:13
@github-actions github-actions bot added area/docs This PR involves changes to the documentation size: small type/docs pr/external Triage Required 🏥 This requires triage labels Sep 8, 2024
Copy link
Contributor

@Alc-Alc Alc-Alc 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 for your contribution 🙂

I am afraid you must have overlooked this. As shown in https://docs.litestar.dev/latest/usage/htmx.html#htmxrequest, request_class=HTMXRequest is set at the app layer and hence is not needed to be specified at any other layers.

app = Litestar(
    route_handlers=[get_form],
    debug=True,
    request_class=HTMXRequest,
    template_config=TemplateConfig(
        directory=Path("litestar_htmx/templates"),
        engine=JinjaTemplateEngine,
    ),
)

In place of your current suggestion, maybe a line (or two) that signifies this can be added?

@cofin cofin removed the Triage Required 🏥 This requires triage label Sep 15, 2024
Copy link
Member

@JacobCoffee JacobCoffee left a comment

Choose a reason for hiding this comment

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

as @Alc-Alc mentioned

@yujinyuz
Copy link
Author

@JacobCoffee @Alc-Alc

Are you suggesting like a comment within the code that the request_class can be added or should I put it somewhere else within the htmx docs?

@Alc-Alc
Copy link
Contributor

Alc-Alc commented Sep 18, 2024

@JacobCoffee @Alc-Alc

Are you suggesting like a comment within the code that the request_class can be added or should I put it somewhere else within the htmx docs?

Heya @yujinyuz, I am suggesting the following

A special :class:`~litestar.connection.Request` class, providing interaction with the
HTMX client. For a request to be considered an :class:`~litestar.contrib.htmx.request.HTMXRequest`, set ``request_class=HTMXRequest``
at a preferred layer (app / router / controller / handler).

over here

HTMXRequest
------------
A special :class:`~litestar.connection.Request` class, providing interaction with the
HTMX client.

Feel free to rephrase or even rework that sentence, my suggestion is for the intent to be clear. The intent being, "add request_class=HTMXRequest at some layer for this to work".

@JacobCoffee FYI.

Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs This PR involves changes to the documentation pr/external pr/internal size: small type/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants