<?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 Ahmed Saka on Medium]]></title>
        <description><![CDATA[Stories by Ahmed Saka on Medium]]></description>
        <link>https://medium.com/@ahmedsaka91?source=rss-d7a6f420c706------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*U-Zv5SW_PuZUCZJZ.</url>
            <title>Stories by Ahmed Saka on Medium</title>
            <link>https://medium.com/@ahmedsaka91?source=rss-d7a6f420c706------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:49:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmedsaka91/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[How to expose a simple RestApi with Spring boot framework (Java)]]></title>
            <link>https://ahmedsaka91.medium.com/how-to-expose-a-simple-restapi-with-spring-boot-framework-java-e56441b6e3b1?source=rss-d7a6f420c706------2</link>
            <guid isPermaLink="false">https://medium.com/p/e56441b6e3b1</guid>
            <dc:creator><![CDATA[Ahmed Saka]]></dc:creator>
            <pubDate>Tue, 05 Jan 2021 20:38:07 GMT</pubDate>
            <atom:updated>2021-01-08T03:50:34.910Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to expose a simple Rest endpoint with Spring boot framework (Java)</h3><p>Hello guys, today I am going to show you how to expose a simple rest-endpoint using spring framework.</p><p>We will need the following to get started:</p><ol><li>IDE (preferably intellij Idea)</li><li>Internet connection</li><li>JDK 1.8+ installed on your computer</li><li>Maven or Gradle (Maven was used in this project)</li><li>Httpie command line client to test the endpoint</li></ol><h3><strong><em>Initializing a spring boot project</em></strong></h3><p>Using spring initializr is one of the easy ways to start a spring boot project. To get started, goto <a href="https://start.spring.io/">Spring initializr</a> to select all required dependecies for the project as shown in below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2z3YPo2kDdP_mKIF0QwlDw.png" /></figure><p>This provides a skeletal structure for the project. We generate then unzip the project, open it up in the IDE and open the pom.xml which contains information like project name, dependencies, jdk version e.t.c.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_LctpCaMEzCuVaFPy9OPw.png" /><figcaption>As we can see below, we have the jdk used for the project as jdk 11 and spring-boot-starter-web as one of the dependencies.</figcaption></figure><p>Now let the coding begin!!!</p><ol><li>Creating the model class: This is just a simple model class for holding and exchanging information. In this case, the model object will be Person with properties like id, name, age, gender and address</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*-x85znu6h6xx2X2AmV1jlw.png" /><figcaption>This includes getter and setter properties</figcaption></figure><p>The id is auto generated when a new Person object is created so there’s no need for setter property.</p><p>2. Controller/ApiSpec: This Intercepts incoming requests gets processed data from the <em>Model</em> and advances that data for rendering. In the context of this project, what the previous statement means is when a controller (<strong><em>PersonController</em></strong>) method(<strong><em>getPeople()</em></strong>) is called, the processed data which is people which is a <strong><em>List&lt;Person&gt;</em></strong> is return.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WP4C_kTtClNoyv1gLEiqbg.png" /><figcaption>PersonController class</figcaption></figure><p>3. Running the app Testing the Api: When we start up the application, it runs on port <strong><em>8080</em></strong> on apache tomcat webserver as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cMyvzeMKKiwt8wrCtPPuVQ.png" /></figure><p>Now we are going to be using a <a href="https://httpie.io/">httpie</a> a command line http client to issue request. After the whole process above is complete, open up the command line and run <strong><em>http GET </em></strong><a href="http://localhost:8080/simple-api/people"><strong><em>http://localhost:8080/simple-api/people</em></strong></a><strong><em> , </em></strong>you should get the results below. This can also be tested via a browser or Postman.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*2v-p3CmP_rnf9XQQPImrUg.png" /></figure><p>4. Conclusion: This is by no means an article with exhaustive details on how to create a RestApi, but it’s a good starting point. To view the source code used for this tutorial, visit <a href="https://github.com/Ahmedsaka/simple-api">https://github.com/Ahmedsaka/simple-api</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e56441b6e3b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>