Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the URL of a request?

I am using Jeresy Jax-RS to build a web service. Now I need to get the url of the request with the port # if one exist.

So if my service runs on http://www.somelocation.com/web/services I want to capture the www.somelocation.com

How can I do this ?

like image 773
John Avatar asked Sep 30 '10 19:09

John


People also ask

What is the request URL?

A request URL consists of an HTTP method, a base URL, and a resource URI. The request header also includes parameters such as the content type and authorization information.

How do I find the URL of API?

API URL. The API is accessed from the URL: http://www.domain.com/api/index.php.

How do I get Golang URL?

To use the url we need to import the o package called net/url. We can pass the url as the argument to the functions of the url. For example, if we have an url and we want to check the port of the given url by calling the function of the url like Port() where u =url. Parse(“www.xyz.com”).

How do I create a GET request?

The GET request consists of the request-line and HTTP headers section. The GET request-line begins with an HTTP method token, followed by the request URI and the protocol version, ending with CRLF. Space characters separate the elements. Below is an example of a GET request to the ReqBin echo server.


1 Answers

You can add a UriInfo parameter to your operation. From there you can access the URL:

@POST
@Consumes({"application/xml", "application/json"})
public Response create(@Context UriInfo uriInfo, Customer customer) {
    ...
}
like image 51
bdoughan Avatar answered Sep 18 '22 14:09

bdoughan