Saturday, June 24, 2017

Getting Http Header Param in Jersey (JAX-RS) Rest


How to read header parameter in Jersey REST - directly into a variable.



//contentType is the String variable which can be used later inside the method.
@GET
public Response getFirstUser(@HeaderParam("Content-Type") String contentType){

 ..
 ...
 System.out.println("content type:" + contentType)
  
 ..
  
}


There is one more way, by reading using @Context  HttpHeader (you can also use this in case you need to get multiple/all header parameters):

//All headers can be read by iterating over headers object.
@GET
public Response getFirstUser(@Context HttpHeaders headers){

  String contentType = headers.getRequestHeader("Content-Type");
  String userAgent= headers.getRequestHeader("user-agent").get(0);
  
  ...
  ... 
  
}





Thursday, June 8, 2017

View Unpushed Git Commits


Working from git command line, you want to check the commited but unpsuhed files. You can use below command:


git log origin/<branch_name>..HEAD

Replace <branch_name> with you feature branch name or the current branch name you are working with.

To create a alias inside you unix shell, you can put this alias inside your .profile or .bashrc file:

alias git-unpushed = !GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD); git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline

And, use git-unpushed from your git client command prompt.

Even better, if you want git client (on your machine) to remember an alias of your liking (that can be used as command later)

$ git config --global alias.unpushed'!GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD); git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline'

Then use git unpsuhed from your git client command prompt.

Prototype

Prototype is another creation pattern. Intent:  - Intent is to create objects by cloning existing instance  - Specify the kinds of obj...