michaelb / sniprun

A neovim plugin to run lines/blocs of code (independently of the rest of the file), supporting multiples languages
MIT License
1.43k stars 46 forks source link

Http client support #253

Closed reavessm closed 11 months ago

reavessm commented 11 months ago

Support for testing rest endpoint via sniprun

Following http file syntax

reavessm commented 11 months ago

At least the basics works:

image

michaelb commented 11 months ago

Nice idea! Thank for contributing!

I'll do a more in-depth review asap

reavessm commented 11 months ago

Thanks! I'll keep this in draft status until I get some of the other http verbs implemented but I'd love feedback, especially on other trait functions and dependency/feature related stuff

reavessm commented 11 months ago

The http parser doesn't curently implement variable substitution, so we will need to upgrade the dependency version once https://github.com/Laeri/http-rest-file/pull/1 gets merged if we want that feature

michaelb commented 11 months ago

Hi @reavessm , I 'fixed' a modification you made due to an incorrect comment of mine (error_truncate stuff, sorry). Do you agree with the latest commit on the 'http' branch I just pushed ?

(it does silently fails if the resp.into_string() errors out, but I don't see that happening in the real-world, or if it does, I hope the status (not-200?) will be indicative enough)

reavessm commented 11 months ago

Oh, I like that! Thank you! That really cleans it up. I'll add that to this PR. I'm going to reopen this for review.

I also think we shouldn't rerun anything in case somethings fails. I can see a situation where you have three REST calls that you want to execute sequentially and if the second one fails, you don't want the third to run. Especially considering this isn't naming any of the requests, I think sequential order is important

michaelb commented 11 months ago

I also think we shouldn't rerun anything in case somethings fails.

Fair enough

returning at the first failure should do the trick

michaelb commented 11 months ago

@reavessm Are you satisfied with the state of your contribution ? As for me, this is good :-)

However, I'd like to do my own dev merge and add some cosmetics (update readme and doc) about HTTP support, so I can't give you permission to merge into master anytime you want via the review system. (Because of how most vim plugin manager works, the master branch has to be carefully synchronized with sniprun's binary releases)

reavessm commented 11 months ago

@michaelb Yep! I can change this to be based on the dev branch. And if you need any help with docs I don't mind helping