Git Product home page Git Product logo

todo-web-service-exercise's Introduction

ToDo web service

Important
This code repository is used as an example project for the training "Docker for JVM projects". It’s not intended for real-world use.

A RESTful web service to managing ToDo items. ToDo items are stored in a database. The underlying implementation is based on Spring Boot built by Maven or Gradle.

Running the service locally

Maven

Execute the goal bootRun with the Maven Wrapper command to bring up the service. Optional arguments can be provided e.g. the server port. The following example starts the application on port 9090.

$ ./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-Dserver.port=9090"

You can activate a profile by passing in the relevant environment. At the moment only prod is supported. The default profile uses a H2 database.

The following example uses the production profile.

$ ./mvnw spring-boot:run -Dspring-boot.run.profiles=prod

Gradle

Execute the task bootRun with the Gradle Wrapper command to bring up the service. Optional arguments can be provided e.g. the server port. The following example starts the application on port 9090.

$ ./gradlew bootRun --args='--server.port=9090'

You can activate a profile by passing in the relevant environment. At the moment only prod is supported. The default profile uses a H2 database.

The following example uses the production profile.

$ ./gradlew bootRun --args='--spring.profiles.active=prod'

Using the API

Once the service is up and running, you can call the exposed CRUD endpoints.

Getting all items

Example command:

$ curl -X GET localhost:8080/todos

Example response:

[
   {
      "id":1,
      "name":"Buy milk",
      "completed":false
   },
   {
      "id":2,
      "name":"Pay bills",
      "completed":true
   }
]

Getting an existing item

Example command:

$ curl -X GET localhost:8080/todos/2

Example response:

{
   "id":2,
   "name":"Pay bills",
   "completed":true
}

Creating a new item

Example command:

$ curl -X POST -H "Content-Type:application/json" -d '{ "name" : "Buy milk", "completed" : false }' localhost:8080/todos

Deleting an existing item

Example command:

$ curl -X DELETE localhost:8080/todos/2

Updating an existing item

Example command:

$ curl -X PUT -H "Content-Type:application/json" -d '{ "name" : "Pay bills", "completed" : true }' localhost:8080/todos/2

todo-web-service-exercise's People

Contributors

bmuschko 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.