-
-
Notifications
You must be signed in to change notification settings - Fork 21
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 support for the REST File format (Jetbrains, VSCode, Neovim) #205
Closed
benfaerber
wants to merge
23
commits into
LucasPickering:master
from
benfaerber:add-http-file-support
Closed
Add support for the REST File format (Jetbrains, VSCode, Neovim) #205
benfaerber
wants to merge
23
commits into
LucasPickering:master
from
benfaerber:add-http-file-support
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@benfaerber Do you think you'll have time to pick this back up? I think a first good step would be to break it into two PRs, one for the base |
@benfaerber I'm closing this since it's inactive. If you'd like to keep working on it feel free to re-open. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add Support for the REST file format (Jetbrains, VSCode, Neovim)
Addresses Issue #122
This PR adds support for the REST file format.
In Jetbrains this file ends with
.http
and has some unique features not supported in this importer (running Javascript, dyanmic variables, etc)In VSCode, Visual Studio, and Neovim this file ends with
.rest
.I use this format quite often and I ported over all the features I use, plus some more. So I think this covers most of the general use cases. Super advanced features are not ported either because of complexity or security risks (running javascript).
Sorry, this is a large PR! A lot of the bulk is unit tests and the test files. I wanted it to be pretty usable before making a PR. This is one of those things where the whole parser has to be complete before it is usable. If the parser is out of scope, I could throw it into a new crate and then we could import from that. The crate would have the basic format parser and then the jetbrains env parser as an optional feature. The issue with that is there would have to be a lot of bridge code to convert types. It would also be annoying because you can't provide implementations for foreign types. I would like some thoughts on this.
Luckily, this project already had
nom
,serde
, andurl
. I had to addhttparse
but that was already in the dependency tree viahyper
.Modules:
/collections/rest_format.rs
This module handles the parsing of the format and the conversion to a slumber collection.
It has some unit tests that cover most use cases but I'm sure I missed something. I ended up calling it
rest_format
instead ofjetbrains
because it works on a variety ofhttp
/rest
file formats for several editors. I ported over only the basic features (requests, comments. variables, names) which makes it editor agnostic.A basic overview of the parser:
httparse
and extract all the request info (headers, query, body, etc)url
crate does not allow parsing of query alone so I had to append a localhost url to the query, then parse that. I did this because the template literals would cause an error in the URL parser. I thought it would be better to useurl
instead of hand rolling a query parser (sounds easy but I'm sure there are some edge cases I'd rather not handle)Authorize
header, parse it and turn it into the slumberAuthentication
struct (supportsBearer
andBasic
)/collections/jetbrains_env.rs
This module parses jetbrains http enviroment files.
This is a JSON file that is comparable to a slumber profile. There is a public and private variant.
Using the commands
import jetbrains-with-public-env
andimport jetbrains-with-private-env
you can include these files into your slumber collection.These files are stored in the same directory as the HTTP file in jetbrains. The importer just searches the directory of the http file to find the envs.
/cli/import.rs
I added the following import targets:
I added the 3 jetbrains formats because it was the simplest way.
I think a custom Jetbrains env type flag might be better (ie
import jetbrains --env private
). Open to ideas.I want to make sure the user knows when a private env is being imported as a lot of people wouldn't want that.
Known Risks
The file format is complex and some obscure use cases could cause errors but I have some good error messages.
QA
Unit tests for most functions.
Checklist
CONTRIBUTING.md
already?CHANGELOG.md
?