Thursday, December 18, 2014

Sample Web-service method in Groovy and how to call it

You might have heard about Webservice.

 Don't just use facebook or twitter or google! 
 Understand how things work in the background. 
 Read this short blog post I wrote to learn how the pages you see and the mobile 
 apps you use communicate with servers.  

Web service is a method of communication between two electronic devices over a network. It is a software function provided at a network address over the Web with the service always on as in the concept of utility computing. The W3C defines a Web service generally as:-
a software system designed to support interoperable machine-to-machine interaction over a network.
Read what web services are from wikipedia and read the code.

Nowadays, This is how almost all new web and mobile apps work.

 class SampleController {  
     def action(String username, String course, String password){  
         return Grade.findByUsernameAndCourseAndPassword(username, course, password)
     }  
 }  

GET
 www.mu.com/sample/action?username=biniam&course=it&password=123  

POST
 www.mu.com/sample/action  
           {  
                "username":"biniam",  
                "course":"it",  
                "password":"123"  
           }  

Tuesday, December 16, 2014

Git Commit with Header and Multi-line Body

I found this interesting answer on Stackoverflow to add Git Commit with Header and Multi-line Body and I wanted to share it.


 git commit -m "Header Comes Here" -m "Multiline body Comes Here.   
 Add a title to your commit after -m enclosed in quotes, 
 then add the body of your comment after a second -m.  
 Press ENTER before closing the quotes to add a line break.  
 Repeat as needed.  
 Then close the quotes and hit ENTER twice to apply the commit."  

Thanks Jon Crowell