-
Notifications
You must be signed in to change notification settings - Fork 35
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
Export request to CURL format #86
Conversation
Also recommendations on code quality and others are really really welcome, i've been trying my best to read all the code i've could to be able to do this because i'm basically rust + gtk noob lmao |
Right now this is only working with raw body format, but im not really sure how to export body for others formats such as |
d6c7f29
to
7ba1ea8
Compare
Another thing is that i added now a copy request contents button, the thing is that i'm not really sure now how could i make it display a little toast like the errors ones but when the user copies the thing... I saw the method error_toast() in window or something similar, but i can't seem to find a way to obtain the window instance from within the code.rs widget, is there any way to fetch it? or at least fetch the toaster widget which is wrapping the app? After this and after discussing about the handling of others formats of body, i think this pr should be ready to review |
Sorry, I am slow to respond. I still need to read the code, but let me say that the screenshot looks incredible and I am in love with how modern the Copy button looks. I agree that the panel could be reused to provide code generation for other programming languages. It reminds me of what regex101 does in their Export dialog. One dialog, many languages. Let me try to provide information here for what you're asking.
That's a very good question that I didn't consider until now. I've just made a test using Firefox to see how do they implement "Copy as cURL" when there is a payload, and it seems that all they do is to just convert to a raw body, similar to when it does a request, and use -d parameters. After all, a urlencoded body like However, it seems that if one of the fields is binary (for instance, files), they don't copy the file to the curl command. I suppose that they don't want random bytes in the clipboard.
There is a method in the Gtk.Application class called I am looking for examples and there is one in app.rs here, but a cast is required from GtkWindow to CarteroWindow. Lines 67 to 70 in 74c5600
To be fair, it's true that the |
Hey! 👋🏻
Don't worry! it's ok :) also thank you, yeah i felt like it would be a great addition since all one wants to do is click one button to get instantly the code :)
Yeah, it would be easier for the user to just do it one single view or panel, 100% agree
Ohh i see, that's interesting, in that case i think all i could do is some kind of parsing for those urlencoded values and put there in that format if they come that way and just ignore the files if that's the actual body.
Ok that's certainly interesting, i could try doing it that way! thank you for the example aswell 👍🏻 |
I think with these last changes it's ready for code review. |
The idea is to implement #63 but in a way that it's open for also implementing #64 since those could be placed in the same panel but with more options in the combobox.
Note
Still this is work in progress and isn't fully done, just leaving this here as a draft to document a little bit the process 😅
Status: Ready for review.