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

There's no way to use request data #12

Closed
mkantor opened this issue Sep 3, 2020 · 5 comments
Closed

There's no way to use request data #12

mkantor opened this issue Sep 3, 2020 · 5 comments
Milestone

Comments

@mkantor
Copy link
Owner

mkantor commented Sep 3, 2020

Dynamic content (executables and templates) should be able to access request data (headers, the request payload, the query string, etc).

See #7 for some notes on security concerns.

@mkantor
Copy link
Owner Author

mkantor commented Sep 4, 2020

Tangentially, I've been thinking about FastCGI. Among (many) other things, it specifies how to hand off request headers and such to the process handling the request. FastCGI support is pretty common in the wild, and many languages have implementations of it (things like PHP's header function would "just work"). There are some Rust libraries, but I haven't dug into them.

It'd suck to give up the conceptual simplicity of the current executables, so maybe FastCGI could be a new type of content rather than replacing executables.

Anyway, this is just a vague idea and might never happen. I thought I'd mention it here since FastCGI defines how to hand off request data.

Regular old CGI, SCGI, etc are worth consideration too. In particular, maybe Operator should use the environment variables defined by CGI to pass request data to executables? That could make it easier for users to leverage old CGI scripts/libraries.

@mkantor
Copy link
Owner Author

mkantor commented Jun 23, 2021

As a minimum viable product for this consider simply adding additional request info (query parameters, request headers/body, etc) to RenderData.

@mkantor
Copy link
Owner Author

mkantor commented Aug 29, 2021

I've decided to take the MVP approach to start with, with CGI support as a separate feature which may or may not be implemented later.

Here's a task list:

Depending on how I decide to handle #13, these may also be in scope:

  • Make request bodies available to templates and executables somehow (ideally as streams, so this might not be as simple as adding another property to RenderData)
  • Make the HTTP method available in RenderData (seems useful whether methods are part of the content directory structure or not)

@mkantor
Copy link
Owner Author

mkantor commented Dec 27, 2021

This is done for now, though as mentioned above there will be more to come with #13.

@mkantor mkantor closed this as completed Dec 27, 2021
@mkantor
Copy link
Owner Author

mkantor commented Feb 5, 2022

It would be cool to provide request body content to executables via STDIN. This would be a natural fit if I can pull off streaming.

More thought is needed as to how streaming could work in templates. Maybe there could be a custom helper to lazily consume the request body—even if the helper blocks to consume the entire stream and allocate a big String/Vec<u8>, at least that would only happen if needed instead of wastefully doing while handling any request. Also, I suppose with {{get x}}, x should always see the same request body stream as the parent template (whether x is an executable or template)?

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

No branches or pull requests

1 participant