mistweaverco / kulala.nvim

A minimal 🤏 HTTP-client 🐼 interface 🖥️ for Neovim ❤️.
https://kulala.mwco.app
MIT License
595 stars 28 forks source link

How to see response headers #13

Closed Mr-LLLLL closed 3 months ago

gorillamoe commented 3 months ago

Currently not possible, but that's something I also want to have implemented.

But I'm not quite sure on how to display them without breaking the current minimalistic approach.

Any ideas?

Maybe require('kulala').run({ response_headers = true }) which will then open up another split with the headers?

I mean, the command would open up 2 splits, if they not already exist, one with the response body and one with the headers.

gorillamoe commented 3 months ago

While implementing a POC I was thinking that it might be better to have them always available and being able to toggle them in the one split via require('kulala').toggle_headers()?

Mr-LLLLL commented 3 months ago

I used rest.nvim before. rest.nvim alway display header in another tab by Press L.dislay response header is not important thing normally. so i think toggle this is better.

gorillamoe commented 3 months ago

I have hard feelings when it comes to default keybindings, so that won't happen, but I will expose a function that you can map to the desired behaviour :)

I will push a wip now so that you can keep hacking :nerd_face:

In the development version the headers of the last run request are saved to you XDG data path. On my system this would be $HOME/.local/share/nvim/tmp/kulala/headers.txt

This should suffice until I have it all set up. Won't take that long :smile:

gorillamoe commented 3 months ago

You can now call require('kulala').toggle_view() to toggle the views (currently body and headers).

If you happen to need to debug response headers all the time and don't care about the the body, you can also call the setup function like so:

require('lazy').setup({
  -- HTTP REST-Client Interface
  {
    'mistweaverco/kulala.nvim'
    config = function()
      require('kulala').setup({
        debug = false, -- Enable debug mode
        default_view = 'headers', -- body or headers
      })
    end
  },
})