The Crystal Programming Language Forum

Making curl-to-crystal tool

Hello!

I made a tool to convert curl commands to crystal http-request code. This project is based on curl-to-ruby, which is based on curl-to-go. I updated curl-to-ruby to Crystal version.

Here is the link of web page.
https://kanezoh.github.io/curl-to-crystal/

And here is the repository. If you like it, plz star my project.

I hope you like and enjoy it!
Also, any bug reports and contributions are welcome!

Thank you!

6 Likes

Nice! If it’s just one request maybe it can be done without instantiating an HTTP::Client, just using HTTP::Client.get. Then you don’t need a URI either.

2 Likes

useless, most of time we need a wrap.

Thank you for your advice!
I made a simple reqest more simple.

input

curl example.com

output

require "http/client"
require "uri"

uri = URI.parse("http://example.com")
response = HTTP::Client.get(uri)

# response.status_code.not_nil!
# response.body.not_nil!

Thank you!

hmmm…

curl-to-go and curl-to-ruby are loved by many programmers, so I think the crystal-version also makes sense.