diff --git a/rest-api/.gitignore b/rest-api/.gitignore
new file mode 100644
index 0000000..33653da
--- /dev/null
+++ b/rest-api/.gitignore
@@ -0,0 +1,31 @@
+
+# Files
+.classpath
+.externalToolBuilders
+.gradle
+.project
+.pydevproject
+.settings
+.sonar
+*~
+*.ipr
+*.iml
+*.iws
+*.swp
+*.DS_Store
+*.snap.debug
+dependency-reduced-pom.xml
+
+# Directories
+.idea/
+.run/
+.venv/
+_site/
+build/
+dist/
+docs/_build/
+gen-java/
+gen-javabean/
+gen-py/
+node_modules/
+target/
diff --git a/rest-api/README.md b/rest-api/README.md
new file mode 100644
index 0000000..ad0e63b
--- /dev/null
+++ b/rest-api/README.md
@@ -0,0 +1,6 @@
+# Overview
+This project can serve as starting point for a REST API.
+
+# Links
+
+[Creating a REST API](https://happycoding.io/tutorials/java-server/rest-api)
diff --git a/rest-api/pom.xml b/rest-api/pom.xml
new file mode 100644
index 0000000..cac412d
--- /dev/null
+++ b/rest-api/pom.xml
@@ -0,0 +1,101 @@
+
+
+ 4.0.0
+
+ rest_api
+ description
+ https://swingbe.de
+ de.swingbe
+ rest_api
+ 0.0.1
+ jar
+
+
+
+ GNU General Public License
+ https://www.gnu.org/licenses/gpl-3.0.txt
+
+
+
+
+ https://github.com/Software-Ingenieur-Begerad/sandbox-java
+
+
+
+
+ UTF-8
+
+
+
+
+ org.json
+ json
+ 20220320
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 4.0.1
+ provided
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.10.1
+
+
+ 11
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.4
+
+
+ package
+
+ shade
+
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+ true
+
+ shaded
+
+
+
+
+ de.swingbe.rest_api.Main
+
+
+
+
+
+
+
+
+
+
+
diff --git a/rest-api/src/main/java/de/swingbe/rest_api/Main.java b/rest-api/src/main/java/de/swingbe/rest_api/Main.java
new file mode 100644
index 0000000..529472d
--- /dev/null
+++ b/rest-api/src/main/java/de/swingbe/rest_api/Main.java
@@ -0,0 +1,9 @@
+package de.swingbe.rest_api;
+
+public class Main {
+
+ public static void main(String[] args) {
+ System.out.println("Hello world!");
+ return;
+ }
+}
diff --git a/rest-api/src/main/java/de/swingbe/rest_api/controller/PersonServlet.java b/rest-api/src/main/java/de/swingbe/rest_api/controller/PersonServlet.java
new file mode 100644
index 0000000..ec416c5
--- /dev/null
+++ b/rest-api/src/main/java/de/swingbe/rest_api/controller/PersonServlet.java
@@ -0,0 +1,47 @@
+package de.swingbe.rest_api.controller;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.swingbe.rest_api.model.Person;
+import de.swingbe.rest_api.storage.DataStore;
+import org.json.JSONObject;
+
+public class PersonServlet extends HttpServlet {
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+
+ String requestUrl = request.getRequestURI();
+ String name = requestUrl.substring("/people/".length());
+
+ Person person = DataStore.getInstance().getPerson(name);
+
+ if (person != null) {
+ String json = "{\n";
+ json += "\"name\": " + JSONObject.quote(person.getName()) + ",\n";
+ json += "\"about\": " + JSONObject.quote(person.getAbout()) + ",\n";
+ json += "\"birthYear\": " + person.getBirthYear() + "\n";
+ json += "}";
+ response.getOutputStream().println(json);
+ } else {
+ //That person wasn't found, so return an empty JSON object. We could also return an error.
+ response.getOutputStream().println("{}");
+ }
+ }
+
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+
+ String name = request.getParameter("name");
+ String about = request.getParameter("about");
+ int birthYear = Integer.parseInt(request.getParameter("birthYear"));
+
+ DataStore.getInstance().putPerson(new Person(name, about, birthYear));
+ }
+}
diff --git a/rest-api/src/main/java/de/swingbe/rest_api/model/Person.java b/rest-api/src/main/java/de/swingbe/rest_api/model/Person.java
new file mode 100644
index 0000000..9a05437
--- /dev/null
+++ b/rest-api/src/main/java/de/swingbe/rest_api/model/Person.java
@@ -0,0 +1,25 @@
+package de.swingbe.rest_api.model;
+
+public class Person {
+ private final String name;
+ private final String about;
+ private final int birthYear;
+
+ public Person(String name, String about, int birthYear) {
+ this.name = name;
+ this.about = about;
+ this.birthYear = birthYear;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getAbout() {
+ return about;
+ }
+
+ public int getBirthYear() {
+ return birthYear;
+ }
+}
diff --git a/rest-api/src/main/java/de/swingbe/rest_api/storage/DataStore.java b/rest-api/src/main/java/de/swingbe/rest_api/storage/DataStore.java
new file mode 100644
index 0000000..5031389
--- /dev/null
+++ b/rest-api/src/main/java/de/swingbe/rest_api/storage/DataStore.java
@@ -0,0 +1,38 @@
+package de.swingbe.rest_api.storage;
+
+import de.swingbe.rest_api.model.Person;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Example DataStore class that provides access to user data.
+ * Pretend this class accesses a database.
+ */
+public class DataStore {
+
+ //this class is a singleton and should not be instantiated directly!
+ private static final DataStore instance = new DataStore();
+ //Map of names to Person instances.
+ private final Map personMap = new HashMap<>();
+
+ //private constructor so people know to use the getInstance() function instead
+ private DataStore() {
+ //dummy data
+ personMap.put("Ada", new Person("Ada", "Ada Lovelace was the first programmer.", 1815));
+ personMap.put("Kevin", new Person("Kevin", "Kevin is the author of HappyCoding.io.", 1986));
+ personMap.put("Stanley", new Person("Stanley", "Stanley is Kevin's cat.", 2007));
+ }
+
+ public static DataStore getInstance() {
+ return instance;
+ }
+
+ public Person getPerson(String name) {
+ return personMap.get(name);
+ }
+
+ public void putPerson(Person person) {
+ personMap.put(person.getName(), person);
+ }
+}
diff --git a/rest-api/src/main/resources/web.xml b/rest-api/src/main/resources/web.xml
new file mode 100644
index 0000000..ffd520e
--- /dev/null
+++ b/rest-api/src/main/resources/web.xml
@@ -0,0 +1,18 @@
+
+
+
+ PersonServlet
+ PersonServlet
+
+
+
+ PersonServlet
+ /people/*
+
+
+