You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have put them in api/lib/tests, alongside health.rs. However, you can put them whereever you like, as long as you keep those two files (rest-api.http, http-client.env.json) together.
How to use the script
Open rest-api.http in your Jetbrains IDE where you have installed the HTTP Client plugin.
At the top of the file tab, select the appropriate environment from Run with:
Click the green double arrow
Observe the results
How the script works
Just like the original api.http file, it's a bunch of http calls (GET, POST, etc) seperated by markers (###). There are placeholders (for example {{host}}), that are filled from the corresponding env file.
GET {{host}}/health HTTP/1.1
HTTP Client also has so-called Response handlers, which are javascript and can access the response object of the previous call, and can also set variables. One such variable is film_id that is used to fill the {{film_id}} placeholder.
#shortened example
POST {{host}}/v1/films
{"some": "data"}
> {%
client.global.set("film_id", response.body["id"]);
# from now on we can use {{film_id}} in the script
%}
I hope this is useful to others, who follow that exhaustive tutorial 😅 👍🏾
The text was updated successfully, but these errors were encountered:
What it is good for
I have taken the vscode testing script file
api.http
and adapted it to a script for the HTTP Client, which is a free plugin for IDEs from Jetbrains.It features (grand word, isn't it)
dev
, remoteshuttle
)film_id
of a newly created filmWhere to find the script
There are two files needed. You can find both of them in this gist: https://gist.github.com/bronsen/509f5087b2b463d0268750bd6f236d87
Please make use of them! 😄
Where you could put the script
I have put them in
api/lib/tests
, alongsidehealth.rs
. However, you can put them whereever you like, as long as you keep those two files (rest-api.http, http-client.env.json) together.How to use the script
rest-api.http
in your Jetbrains IDE where you have installed the HTTP Client plugin.Run with:
How the script works
Just like the original
api.http
file, it's a bunch of http calls (GET, POST, etc) seperated by markers (###
). There are placeholders (for example{{host}}
), that are filled from the corresponding env file.HTTP Client also has so-called Response handlers, which are javascript and can access the response object of the previous call, and can also set variables. One such variable is
film_id
that is used to fill the{{film_id}}
placeholder.I hope this is useful to others, who follow that exhaustive tutorial 😅 👍🏾
The text was updated successfully, but these errors were encountered: