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 JsonLines extractor and response #1093

Merged
merged 8 commits into from
Jun 20, 2022
Merged

Add JsonLines extractor and response #1093

merged 8 commits into from
Jun 20, 2022

Conversation

davidpdrsn
Copy link
Member

@davidpdrsn davidpdrsn commented Jun 15, 2022

This adds JsonLines which is a newline delimited JSON extractor and response. Its partly inspired by actix_web_lab::respond::NdJson.

I had a use case for this today and figured it makes sense to upstream.

axum-extra/src/ndjson.rs Outdated Show resolved Hide resolved
axum-extra/src/lib.rs Outdated Show resolved Hide resolved
@FSMaxB
Copy link
Contributor

FSMaxB commented Jun 16, 2022

Just a small comment about the naming. NdJson doesn't really explain what it is, I suggest calling it JsonLines instead. This would also be in line with https://jsonlines.org/

@davidpdrsn
Copy link
Member Author

@FSMaxB Good point! I had only heard of "newline delimited json" but seeing as json lines appears to be thing I like that name more.

davidpdrsn and others added 3 commits June 16, 2022 13:08
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
@davidpdrsn davidpdrsn changed the title Add NdJson extractor and response Add JsonLines extractor and response Jun 17, 2022
Copy link
Member

@jplatte jplatte 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 but it looks good from that.

@@ -67,6 +68,9 @@ pub mod extract;
pub mod response;
pub mod routing;

#[cfg(feature = "json-lines")]
pub mod json_lines;
Copy link
Member

Choose a reason for hiding this comment

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

In axum, only the Json type is exported at the root, not the json module. Does this deviate from that because there's more types to expose?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly!

@davidpdrsn davidpdrsn merged commit 6b6a415 into main Jun 20, 2022
@davidpdrsn davidpdrsn deleted the ndjson branch June 20, 2022 18:49
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.

None yet

3 participants