<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Emre Avara on Medium]]></title>
        <description><![CDATA[Stories by Emre Avara on Medium]]></description>
        <link>https://medium.com/@emre_avara?source=rss-aced111ec364------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rzCG4UZWqOFpAFy4gpDF9Q.jpeg</url>
            <title>Stories by Emre Avara on Medium</title>
            <link>https://medium.com/@emre_avara?source=rss-aced111ec364------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 13:08:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emre_avara/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding Spring Boot Controller Layer Annotations: Beginner’s Guide]]></title>
            <link>https://medium.com/@emre_avara/understanding-spring-boot-controller-layer-annotations-beginners-guide-3708cd9f68ee?source=rss-aced111ec364------2</link>
            <guid isPermaLink="false">https://medium.com/p/3708cd9f68ee</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[controller]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Emre Avara]]></dc:creator>
            <pubDate>Fri, 05 Apr 2024 00:06:35 GMT</pubDate>
            <atom:updated>2024-04-05T00:07:54.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*tGsMT-8B0BCYLHEqyNRkrg.png" /></figure><p>Building robust and efficient APIs plays an important role in today’s modern web development. As Controllers exist almost in every Spring Boot Application where HTTP requests are handled and mapped to the methods, Spring Boot provides a variety of annotations for Controller layer to manage them effectively. In this post, we will discover their usages and purposes.</p><h3>Spring Boot Controller Layer Annotations</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*blcXoGjg8FakSim7KiR5bQ.png" /></figure><h4>1. @RestController</h4><p>This annotation is a combination of @Controller and @ResponseBody. When you annotate a class with @RestController, unlike @Controller it will return an object instead of view. This object will be converted to JSON or XML and can be read from body of HTTP response. It is used to develop RESTful web services.</p><pre>@RestController<br>public class ProductController {<br><br>}</pre><h4>2. @RequestMapping</h4><p>This annotation binds the HTTP request to particular handlers in Spring MVC within controller classes (i.e @RestController). It could be used both for classes and for methods in classes.</p><pre>@RestController<br>@RequestMapping(&quot;/api/v1/products&quot;)<br>public class ProductController {<br><br>}</pre><h4>3. @GetMapping @PostMapping @DeleteMapping @PutMapping @PatchMapping</h4><p>These annotations are used to map HTTP requests to corresponding handler methods. They indicates that annotated method will handle the mapped request with corresponding url (i.e. GET, POST, DELETE, PUT, PATCH respectively). They are shortcuts of @RequestMapping with path and method.</p><pre>@RestController<br>@RequestMapping(&quot;/api/v1/products&quot;)<br>public class ProductController {<br><br>  @GetMapping(&quot;/get&quot;)<br>  public String getProduct(){<br>    return &quot;handles HTTP GET requests&quot;;<br>  }<br><br>  @RequestMapping(path = &quot;/getwithrequestmapping&quot;, method = RequestMethod.GET)<br>  public String getWithRequestMapping(){<br>    return &quot;handles HTTP GET requests with @RequestMapping annotation&quot;;<br>  }<br><br>  @PostMapping(&quot;/post&quot;)<br>  public String postProduct(){<br>    return &quot;handles HTTP POST requests&quot;;<br>  }<br><br>  @RequestMapping(path = &quot;/postwithrequestmapping&quot;, method = RequestMethod.POST)<br>  public String postWithRequestMapping(){<br>    return &quot;handles HTTP POST requests with @RequestMapping annotation&quot;;<br>  }<br><br>  @DeleteMapping(&quot;/delete&quot;)<br>  public String deleteProduct(){<br>    return &quot;handles HTTP DELETE requests&quot;;<br>  }<br><br>  @PutMapping(&quot;/put&quot;)<br>  public String putProduct(){<br>    return &quot;handles HTTP PUT requests&quot;;<br>  }<br>}</pre><h4>4. @PathVariable</h4><p>This annotation is used to get the variable from the url and pass it as a parameter to the corresponding methods annotated with HTTP request annotations. It helps us to make our request dynamic and handle them within the methods.</p><pre>@RestController<br>@RequestMapping(&quot;/api/v1/products&quot;)<br>public class ProductController {<br><br>  @GetMapping(&quot;/{id}&quot;)<br>  public String getProduct(@PathVariable String id){<br>    return &quot;handles HTTP GET requests. Id: &quot; + id ;<br>  }<br>}</pre><p>In this example, we are getting <em>id </em>as @PathVariable to get the product with given id. We can also chain multiple path variables in the url.</p><h4>5. @PathParam</h4><p>In order to get the parameters in the url we are using @PathParam annotation. It gets the values from the url parameters and bind them with the parameters of the methods. This is not a common usage in Spring MVC. As alternative we are using @PathVariable.</p><pre>@RestController<br>@RequestMapping(&quot;/api/v1/products&quot;)<br>public class ProductController {<br><br>  @PostMapping(&quot;/post&quot;)<br>  public String postProduct(@PathParam(&quot;name&quot;) String name){<br>    return &quot;handles HTTP POST requests to save product with name: &quot; + name ;<br>  }<br>}</pre><p>In this example we are sending a post request to “/api/v1/products/post?name=Test” url with “?name=Test” params. @PathParam enables us to get name and bind it with the parameter of the method. We can use multiple annotations in a method.</p><h4>6. @RequestBody</h4><p>This annotation enable us to get values from request body and map them to the specified object next to it when we would like to get the data from the body of the request. Usually it is used with POST, PUT or PATCH requests where data is usually stored in request body.</p><pre>@RestController<br>@RequestMapping(&quot;/api/v1/products&quot;)<br>public class ProductController {<br>  @PutMapping<br>  public String putProduct(@RequestBody Product product){<br>    return &quot;handles HTTP PUT requests and changes the product name to :&quot; + product.getName();<br>  }<br>}<br><br>// Product.java<br>@Getter<br>@AllArgsConstructor<br>@Builder<br>public class Product {<br>  private Long id;<br>  private String name;<br>}</pre><p>In this example we are getting updated product in the request body and mapping it to Product object with the @RequestBody annotation.</p><h3>Conclusion</h3><p>As a result we have learned the usages and objectives of Spring Boot Controller layer annotations where we handle HTTP requests and process them. To practice them, you can copy and paste the given examples and send request via Postman oder curl.</p><h3>Support Me</h3><p>Enjoyed this article? Let me know your thoughts in the comments below! Your feedback fuels my passion for writing and helps me create content that resonates with you. Don’t forget to hit the follow button to stay updated on my latest articles, and if you found this piece valuable, a round of applause would mean the world to me! Thanks for reading and being part of this journey.</p><p>Follow me for more coding adventures and insights.</p><p>Youtube: <a href="https://www.youtube.com/@AvaraCodes">https://www.youtube.com/@AvaraCodes</a></p><p>LinkedIn: <a href="https://www.linkedin.com/in/emre-avara/">https://www.linkedin.com/in/emre-avara/</a></p><p>Instagram: @avaracodes</p><p>Github: <a href="https://github.com/emreavara">https://github.com/emreavara</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3708cd9f68ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Git: A Step-by-Step Guide for Beginners]]></title>
            <link>https://medium.com/@emre_avara/getting-started-with-git-a-step-by-step-guide-for-beginners-26ec980c690b?source=rss-aced111ec364------2</link>
            <guid isPermaLink="false">https://medium.com/p/26ec980c690b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[junior-developer]]></category>
            <category><![CDATA[version-control-system]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Emre Avara]]></dc:creator>
            <pubDate>Mon, 01 Apr 2024 00:46:47 GMT</pubDate>
            <atom:updated>2024-04-01T01:06:05.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*57yjo_r7DtVTbh8n" /><figcaption>Photo by <a href="https://unsplash.com/@charlesdeluvio?utm_source=medium&amp;utm_medium=referral">charlesdeluvio</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Introduction to Version Control and Git</strong></h3><p>In today’s agile software development teams, version control system usage is inevitable. Version Control System tracks the change in source code so that user can move between different versions. You can think of it as checkpoints in the game. Whenever you die or fail, you can go back to checkpoint and go on playing. Git is a distributed version control that is also commonly used in software development.</p><h3><strong>Git vs Github</strong></h3><p><strong>Git</strong> is a version control system that enables developers to move between versions.</p><p><strong>Github</strong> is a web-based platform and hosting service that provides additional features built on top of Git. It hosts git repositories that enables users to store and share their source code.</p><h3>Basic Concepts</h3><p><strong>Repository: </strong>a storage where Git stores the history and content of a project. Simply it is a place that you store your source code</p><p><strong>Commit: </strong>a snapshot of the project at a specific point in time. Like checkpoints in computer games</p><p><strong>Branch: </strong>your own space to work on your task</p><p><strong>Remote: </strong>repository hosted on a server in order to collaborate with others</p><h3>Setting up Git</h3><p>Follow the instructions from the link below depending on your operating system: <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">https://git-scm.com/book/en/v2/Getting-Started-Installing-Git</a></p><p>To keep the track of the author of your commit, it is necessary to configure username and email address.</p><ol><li>Open a terminal</li><li>Configure your username</li></ol><pre># git config --global user.name &quot;Emre Avara&quot; # your name here</pre><p>3. Configure your email address</p><pre># git config --global user.email emre_avara@hotmail.com # your email here</pre><p>4. Check your settings</p><pre># git config --list<br>...<br>user.name=Emre Avara<br>user.email=emre_avara@hotmail.com<br>...</pre><h3>Create Your First Repository</h3><p>To create your first git repository, go to the folder that you are going to create your project and type the following command from terminal:</p><pre># git init</pre><p>This command turns the current directory into a git repository. It will create a hidden .git folder which contains all required configurations for your git repository.</p><h3>…or Clone Existing Repository</h3><p>If you would like to clone existing repository from a remote repository, you should clone the already initiated repository.</p><p><strong>git clone &lt;url&gt;:</strong> clones the existing repository to current directory into the folder with the name of repository. You can copy the url from the cloning options. <strong>Note: </strong>If you would like to use SSH, it is required to add SSH key.</p><pre># git clone git@github.com:emreavara/DesignPatterns-Java.git</pre><h3><strong>Create and Switch to a New Branch</strong></h3><p>As we are working in a team but on separate tasks, we need to create new branches from main/master branch and should go on our work on that branch. It enables us to work in parallel, isolate our work and review the code on that branch. It also could be used for release and risk management. Let’s create our new branch:</p><p><strong>git branch &lt;branch_name&gt;: </strong>creates a new branch with name “branch_name”</p><p><strong>git checkout &lt;branch_name&gt;: </strong>switches to the branch named as “branch_name”</p><p><strong>git checkout -b &lt;branch_name&gt;:</strong> combines both command “git branch &lt;branch_name&gt; &amp;&amp; git checkout &lt;branch_name&gt;”and creates and switches to the branch named as “branch_name”</p><pre># git branch &lt;branch_name&gt;<br># git checkout &lt;branch_name&gt;<br>or<br># git checkout -b &lt;branch_name&gt;</pre><h3><strong>Your First Commit</strong></h3><p>Congratulations! You created your first repository and now it is time to do your initial commit. Let’s create a file named as “hello.txt” and write “Hello World” in it from terminal.</p><pre># echo &quot;Hello World&quot; &gt; hello.txt</pre><p><strong>git add . :</strong> adds your changes to the stage. You can specify file name to be staged or put simply “.” after command to stage all changes.</p><pre># git add hello.txt # to add changes one by one<br>or<br># git add . # to add all changes</pre><p><strong>git status: </strong>shows the current state of the files. When it is green it means that they are staged and when it is red, they are modified, deleted or untracked.</p><figure><img alt="new file that is already added to stage" src="https://cdn-images-1.medium.com/max/948/1*p_b2txxp5opqe8o40_XBXQ.png" /><figcaption>Staged new file</figcaption></figure><p><strong>git commit -m “Add message”: </strong>commits changes with a message. The message should be imperative. You should commit as much as possible after every meaningful and functional change to keep track of your changes clearly and neat.</p><pre># git commit -m&quot;Your imperative message here&quot;<br># git commit -m&quot;Add First Commit&quot;</pre><p><strong>git log: </strong>shows the commits with author, commit id, date, and message info. Tip: if you would like to see the shortened commit id and commit message line by line you can use “git log --oneline”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*Pu4qS3tyN7Rb06Ba11JRzQ.png" /></figure><h3>Add Remote Repository</h3><p><strong>*</strong>If you have already cloned an existing repository, you can skip this part and directly push your changes because this linking is already created when you cloned your repository.</p><p>If you initiated a new repository in your local machine, you need to configure a remote repository link so that you can push your changes to a remote repository. To add this link you can follow the instructions of that repository or simply copy the link of it and add as remote repo.</p><p><strong>git remote add origin &lt;url&gt;: </strong>configures a remote repository to push the committed changes. You can not push changes that are not committed.</p><pre># git remote add origin git@github.com:emreavara/empty-demp.git</pre><h3>Time to Push Your Changes</h3><p>now everything is set and time to push your changes.</p><p><strong>git push origin &lt;branch_name&gt;: </strong>sends your changes to remote repository under your branch name. From now on everyone who has access to this repo can see your changes under your branch.</p><p>If you see an error message that states that this branch does not exist in the remote repository, then you should set its upstream. This happens because you created this branch locally and remote repository does not know about it.</p><p><strong>git push — set-upstream origin &lt;branch_name&gt;: </strong>sets the upstream branch of local branch</p><h3>Conclusion</h3><p>Amazing work! You have already initiated or cloned your repository, have done required changes and pushed them to a remote repository. As following steps you can create a Pull Request (PR) for code review or merge it to main/master branch.</p><h3>Summary of Commands</h3><pre># To init or clone a repository<br># git init <br>or <br># git clone &lt;url&gt;<br>_________________________________________________________<br># To create a branch and switch to it<br># git checkout -b &lt;branch_name&gt;<br>_________________________________________________________<br># To add and commit your changes<br># git add .<br>_________________________________________________________<br># To check status<br># git status<br>_________________________________________________________<br># To commit your changes<br># git commit -m &quot;Add your message&quot;<br>_________________________________________________________<br># To see your change in logs<br># git log<br>_________________________________________________________<br># To push your committed changes<br># git push origin &lt;branch_name&gt;</pre><h4>Support Me</h4><p>Enjoyed this article? Let me know your thoughts in the comments below! Your feedback fuels my passion for writing and helps me create content that resonates with you. Don’t forget to hit the follow button to stay updated on my latest articles, and if you found this piece valuable, a round of applause would mean the world to me! Thanks for reading and being part of this journey.</p><p>Follow me for more coding adventures and insights.</p><p>Youtube: <a href="https://www.youtube.com/@AvaraCodes?source=about_page-------------------------------------">https://www.youtube.com/@AvaraCodes</a></p><p>LinkedIn: <a href="https://www.linkedin.com/in/emre-avara/?source=about_page-------------------------------------">https://www.linkedin.com/in/emre-avara/</a></p><p>Instagram: @avaracodes</p><p>Github: <a href="https://github.com/emreavara?source=about_page-------------------------------------">https://github.com/emreavara</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26ec980c690b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>