Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Shorthand for -H Content-Type:application/json #12

Open
kikito opened this issue Dec 18, 2015 · 3 comments
Open

Shorthand for -H Content-Type:application/json #12

kikito opened this issue Dec 18, 2015 · 3 comments

Comments

@kikito
Copy link

kikito commented Dec 18, 2015

Writing all that every time is one of my grips with curl. Maybe crul could offer an alternative to that repetitiveness.

I am thinking either a special action (curl post.json ...) or a flag (maybe repurposing -j for that, and creating a format flag, i.e. --format json)

@porras
Copy link
Owner

porras commented Dec 18, 2015

Thanks!

Several ideas I had in mind related to this (which I also find annoying):

  • --content-type json. not much shorter, but much nicer
  • Autodetection from extension when using a file (@data.json, @data.xml, etc.), which is my 90% usecase
  • Real autodetection is probably possible (try to parse as JSON and XML, if it doesn't error, it must be that format)
  • Coupling with formatters (90% of the time, the format you send is the format you expect), so -j/--json or -x/--xml might set both Content-Type and formatter

☁️⚡️ <- brain storm

What do you think?

@kikito
Copy link
Author

kikito commented Jan 1, 2016

I have thought about this and I think coupling with the formatter is harmless enough. So +1 to making -j automatically set the header.

@jamiecook
Copy link

Coming here in 2022 to say I still think this is a good idea

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

No branches or pull requests

3 participants