0

I have a REST call to Java services which does a POST to the path

localhost:8080/api/xyz 

and returns the response. The response of course has the response.header['location'] with a correct location with ID

'xyz/{id}'    

For my further steps in the method I just need to extract ONLY the 'id' part from the 'location'. Right now this is what I am doing,

(response.header['location'].split('/'))[1]

Is there a better way to get around this?

Abhi
  • 165
  • 1
  • 9
  • This will fail if the location field value would be a full URI, right? Better resolve it first against the base URI, then use an URI parser to extract the path, then proceed. – Julian Reschke Mar 12 '14 at 17:01

1 Answers1

0

One of the solution provided by rails:

# routes.rb
get '/api/:id'

# view or controller
params[:id]
itsnikolay
  • 17,415
  • 4
  • 65
  • 64