Skip to content

TrieTreeTechnologies/tttjenkins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToDo web service

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 Gradle. The provided Jenkinsfile defines a build pipeline definition for creating, pushing and deploying a Docker image of the application.

Running the service locally

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 dev and prod is supported. The default profile uses a H2 database. The dev profile assumes the usage of a PostgreSQL database for development purposes. The prod profile is used for production environments.

The following example uses the development profile.

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

Running the service in Docker container

Using the default profile:

$ docker run -p 8080:8080 -t bmuschko/todo-web-service

To use the production profile, pass in the SPRING_PROFILES_ACTIVE environment variable:

$ docker run -e "SPRING_PROFILES_ACTIVE=prod" -p 8080:8080 -t bmuschko/todo-web-service

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published