Code Monkey home page Code Monkey logo

java_restapi_bmiberechnung's Introduction

REST-API "BMI-Berechnung" (Java-Servlet mit Jetty)


Java-Programm zur Bereitstellung einer einfachen REST-API zur Berechnung des Body-Mass-Index (BMI). Der BMI wird durch Division des Körpergewichts in kg durch die Größe in Metern berechnet. Je nach Geschlecht kann anhand des BMI dann eine Aussage getroffen werden, ob die Person normal-, unter- oder übergewichtig ist.


Siehe auch dieses Repository für eine Beispiel-App, die eine REST-API mit Java implementiert, allerdings mit dem Framework Spring Boot.



REST-API-Methode


Wenn das Programm auf dem lokalen Rechner gestartet wird, dann ist die REST-API-Methode (Endpoint) für die BMI-Berechnung unter der folgenden URL verfügbar:

http://localhost:8080/bmiberechnung/

Beim Aufruf dieser REST-API-Methode müssen immer die folgenden drei URL-Parameter übergeben werden:

  • gewicht : Gewicht in kg (ganzzahlig)
  • groesse : Körpergröße in cm (ganzzahlig)
  • geschlecht: Entweder mann oder frau

Beispiel für eine zulässige URL:

http://localhost:8080/bmiberechnung/?gewicht=75&groesse=180&geschlecht=mann

Wenn nur einer dieser URL-Parameter nicht gesetzt ist oder einen ungültigen Wert hat, dann wird eine Exception geworfen.


Doku dieser REST-API mit Swagger UI:

https://mdecker-mobilecomputing.github.io/Java_RestAPI_BmiBerechnung/



Jetty


Das Java-Programm verwendet Jetty als eingebetteten Servlet-Container. Ein Servlet ist eine Java-Klasse, die HTTP-Anfragen (als Web-Server-Anfragen) beantworten kann.

Jetty befindet sich in Form einer Jar-Datei im lib/-Ordner dieses Projekts. Die neueste Version der Datei jetty-all-<version>.jar kann von hier heruntergeladen werden.

Siehe auch dieses Tutorial für die Verwendung von Jetty, und hier für die API-Dokumentation.



License


See the LICENSE file for license rights and limitations (BSD 3-Clause License).


Third-Party-Libraries:

  • Jetty is dual licensed under the Apache License 2.0 and Eclipse Public License 1.0, see here.

  • Jackson is licensed under the Apache License 2.0, see here.


The jar files for these third-party libraries (one jar file for Jetty, and three for Jackson) are contained in this repositories folder lib.


swagger-ui-dist, which is used to display the API definition in file osa.yml, is licensed under the Apache License 2.0, see here. These files are contained in folder docs of this repository, so they can be served by GitHub Pages. In file docs/index.html the URL to file oas.yml from this repository was inserted.


java_restapi_bmiberechnung's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.