Sunday 15 March 2015

java - Fixed Rest Endpoints -



java - Fixed Rest Endpoints -

i have war file deployed on tomcat ( /var/lib/tomcat7/webapps folder ), say, rest-api-webapp-0.0.1.war access rest endpoint check, exposed in war, utilize curl in format curl -x post -h "content-type:application/x-www-form-urlencoded" -d "remarks=tester" https://localhost:8080/rest-api-webapp-0.0.1/check problem face is, whenever patch/major/minor versions of webapp, need alter curl appropriately (say version 0.1.4, curl must alter curl -x post -h "content-type:application/x-www-form-urlencoded" -d "remarks=tester" https://localhost:8080/rest-api-webapp-0.1.4/check. donot wish alter way client calls endpoint (because requires client upgrade app, resent , see high maintenance) can avoided doing create symbolic link below ln -s rest-api-webapp-0.0.1.war rest-api within /var/log/tomcat7/webapps folder whennever version, alter symlink point new version , client need not utilize new version of api. in effect, need api endpoint fixed , not alter , when versions on server. for ex: need endpoint fixed https:gva.atr.in/colouring-api/check , whenever have major alter in controllers , need update symlink , not alter endpoint. if find approach flawed, please show me right direction have been trying read past 2 days, found less articles address problem.

i read tomcat documentation , realised need create symbolic link war file , give symbolic file war extension. if have in tomcat webapps directory /var/lib/tomcat7/webapps user1$ ls drwxr-xr-x 11 user1 wheel 374 oct 19 21:52 . drwxr-xr-x 9 user1 admin 306 oct 19 19:36 .. drwxr-xr-x 19 user1 wheel 646 aug 29 20:19 root drwxr-xr-x 55 user1 wheel 1870 aug 29 20:19 docs drwxr-xr-x 4 user1 wheel 136 oct 19 19:46 rest-api-webapp-0.2.1 -rw-r--r-- 1 user1 wheel 48258097 oct 19 19:46 rest-api-webapp-0.2.1.war drwxr-xr-x 7 user1 wheel 238 aug 29 20:19 host-manager drwxr-xr-x 8 user1 wheel 272 aug 29 20:19 manager this, ln -s rest-api-webapp-0.2.1.war rest-api.war directory looks (wait sometime tomcat engine deploy new war) drwxr-xr-x 11 user1 wheel 374 oct 19 21:52 . drwxr-xr-x 9 user1 admin 306 oct 19 19:36 .. drwxr-xr-x 19 user1 wheel 646 aug 29 20:19 root drwxr-xr-x 4 user1 wheel 136 oct 19 21:52 rest-api drwxr-xr-x 4 user1 wheel 136 oct 19 19:46 rest-api-webapp-0.2.1 -rw-r--r-- 1 user1 wheel 48258097 oct 19 19:46 rest-api-webapp-0.2.1.war lrwxr-xr-x 1 user1 wheel 25 oct 19 21:51 rest-api.war -> rest-api-webapp-0.2.1.war drwxr-xr-x 7 user1 wheel 238 aug 29 20:19 host-manager drwxr-xr-x 8 user1 wheel 272 aug 29 20:19 manager if needed restart tomcat , can utilize curl command this curl -x post -h "content-type:application/x-www-form-urlencoded" -d "remarks=tester" https://localhost:8080/rest-api/check totally not bothering major, minor, patch versions. need 1 time have new version unlink rest-apiln -s rest-api-webapp-x.y.z.war rest-api.war

java tomcat7 war versioning endpoint

No comments:

Post a Comment