I want to know if it's possible to add a "prefix" to all request URLs in Postman?
Normally a request looks like this:
HERE
http://localhost:8000/test
But I want to just put:
/test
And put the http://localhost:8000 like a global URL.
I ask this because I swap so much from local to server for same URL and I would like to just change one URL and not URLs for all requests all the time.
Have you looked at using an environment file?
https://www.getpostman.com/docs/v6/postman/environments_and_globals/manage_environments
Add a variable called url with the http://localhost:8000 value. You can then use this value in the URL like {{url}}.
If your requests are constructed like {{url}}/test - You can create as many environments as you like with the url variable different in each one. So by changing the environment this will point your requests at a local, staging or production server.
Related
Let's say that I have a POST endpoint in my Rails app, in which it gets a param called state, which will be an integer of either 200 or 503.
How can I make the Robots.txt file respond with the given state from that POST endpoint, I mean I need a way to control the response code of that only file (Robots.txt) depending on that POST endpoint.
BTW, question is not about how to store that state or something, it's only about how to change the response code of a public file?
Is that possible?
What I have in mind for this and trying now is to have a controller action matching the robots.txt route, but I feel this is so silly to do.
Yes, if you want Rails to be involved in deciding the response for a given URL, then you're going to want to define a controller action to handle those requests.
You can use send_file to actually do the file-sending part.
Depending on your web server's configuration, it's likely you'll need the actual robots.txt file to be stored somewhere other than public/ -- otherwise it might get served without Rails even having a chance to get involved.
You could instead arrange to rewrite your nginx (say) configuration file at runtime, based on what response code you want... but I think that would be silly to do.
A more practical middle-ground would be to have Rails create or delete a marker file, and then use a conditional in the nginx configuration based on whether that file exists. That would be an nginx question though... and would get complicated if you have more than one server.
Is it possible to use environment variables into url parameters with postman?
See picture below for example :
Yes. I'm using it.
This is my screen.
My IP is 192.168.0.38 like below.
Now, I'm working my laptop.
But, If I'm done working, I'll change hostName to the server domain.
it's 100% possible, I am using it currently.
So I have a controller action that renders json.. I can visit the url in the browser and see the json data, verifying that the route is working properly...
Yet, if I do:
uri = URI("#{request.protocol}#{request.host_with_port}/my_controller/action")
Net::HTTP.get(uri)
I get "Timeout::Error: Timeout::Error"
... ?
You're using a single-threaded HTTP server, i.e. Webrick. This means that it will only be able to serve one request at a time. You're attempting to make a request to the webserver from within the webserver itself. It won't be able to complete this action because of now hopefully obvious reasons.
Use a different web server, such as Thin, that would allow for this, or choose a different way to do this.
Can the App proxy be used to pass through various ID's for a separate backend rails app?
I have the case where we've implemented a subscription system in a separate rails app, but we want to show the user their subscriptions from Shopify. To do this I would like to add an app proxy on Shopify, such as:
Proxy Url: subscriptions.com/api/customers/subscriptions
Proxy Path: /a/customers
But I'd like to be able to proxy /a/customers/:customer_id/subscriptions, maybe even /a/customers/:customer_id/subscriptions/:id (for a show subscription liquid response), so concatenating the ids into the url is my main goal.
On the rails side I can easily extract the path_prefix from the params, its a matter of how Shopify is matching the Proxy Paths I guess.
Is this at all possible? Or is there another way around this problem?
The extra path components get appended to the Proxy URL. The Shopify Application Proxy documentation even provides an example showing this in the Proxy Request section.
So for you example, where the proxy url is http://subscriptions.com/api/customers/subscriptions and the proxy path is /a/customers then a request to /a/customers/:customer_id/subscriptions will be proxied to http://subscriptions.com/api/customers/subscriptions/:customer_id/subscriptions
So it sounds like the proxy request is already exactly what you want.
This is what I would like to achieve, but I am a bit of a DNS noob:
1) I have a webapp running on a VPS at myfirstdomain.com/MyApp
2) I want this: going to myapp.myOTHERdomain.com should be heading to myfirstdomain.com/myApp without redirecting using a php script or doing some CURL business. So the url in the addressbar of the browser should stay the same.
Is this possible by doing something with DNS (or some different solution)? I own both domains.
Within DNS, it is not possible to redirect to a subdirectory, but what you can do is create a CNAME record like this:
myapp.myOTHERdomain.com. IN CNAME myfirstdomain.com
That way myapp.myOTHERdomain.com will point to the A record for myfirstdomain.com.
You may configure your webserver to do the HTTP redirect.