hurl.nvim icon indicating copy to clipboard operation
hurl.nvim copied to clipboard

Feature/url show and repeat history

Open Xouzoura opened this issue 4 months ago • 5 comments

WHAT

Added two features that I have made that might be helpful for others.

  • Re-run last query that was made (helpful so that this can be done anywhere and not a specific hurl file) through the HurlRerun
  • Add the url in the headers to know against which endpoint the hurl command was run (found it difficult to check).

WHY

Not sure if that's needed, but for me I find quite helpful to be able to rerun last request without having to go to the hurl file. Then if you make a change anywhere, you can rerun and the hurl command and see the results.

For the url, I think it makes sense to be able to see the url of the request in the endpoint headers (especially when this is not a localhost where you can see directly, but also makes easier to copy paste things. Not sure if it should go on the headers, added it there for simplicity.

So feel free to reject if you find this redundant.

HOW

  • The rerun is done by caching with deepcopy the last opts through the HurlRerun command.
  • The url acquisition is done by using the hurl file and finding the GET/POST/PUT/DELETE and using that url. Bonus is that if something is parameterized, you have the option to select if you want the proper url or the parameterized url, based on the global config. Example: url | GET {{HOST}}/user/group-accesses or url | GET localhost:8000/user/group-accesses

Screenshots (if appropriate):

Screenshot from 2024-10-07 11-11-34

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [X] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ ] Linter
  • [ ] Tests
  • [ ] Review comments
  • [ ] Security

[!IMPORTANT] Add rerun command and URL display feature to Hurl plugin, enhancing request management and visibility.

  • Features:
    • Add HurlRerun command in main.lua to rerun the last executed request using cached options.
    • Display request URL in response headers in popup.lua and split.lua if url.show is enabled in config.
  • Configuration:
    • Add url config in init.lua with options show and format_without_params.
  • Utilities:
    • Implement get_url_from_hurl_file() and convert_url_to_proper_format() in utils.lua to extract and format URLs from Hurl files.

This description was created by Ellipsis for d7e952a0cba6773594e911acdf4ce095234a4072. It will automatically update as commits are pushed.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new url configuration for enhanced URL handling.
    • Added a HurlRerun command to easily rerun the last executed HTTP request.
    • New utility functions for extracting and formatting URLs from .hurl files.
  • Improvements

    • Enhanced header population to include URLs in responses.
    • Improved overall usability of the Hurl command with better request management.

Xouzoura avatar Oct 07 '24 09:10 Xouzoura