All Projects → soushin → spring5-kotlin-application

soushin / spring5-kotlin-application

Licence: other
This repository contains the todo list application that implemented by Spring Boot 2.0.5.RELEASE (support kotlin).

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language
go
31211 projects - #10 most used programming language
Makefile
30231 projects

spring5-kotlin-application

Overview

This repository contains the todo list application implemented by Spring Boot 2.0.5.RELEASE (support kotlin).

Motivation

HTTP routing service and gRPC clinet both applications are able to run on Spring Framework 5.0 ? I want to know that.
So that this repository of applicaiton developed according to following diagram.

diagram

Apis

Create task

$ curl -X POST http://localhost:8080/api/task/ -H "Content-Type: application/json" -d '{"title": "remember the milk"}'
  [{"title":"remember the milk"}]%

Update task

$ curl -X PUT http://localhost:8080/api/task/2 -H "Content-Type: application/json" -d '{"title": "remember the eggs"}'
  [{"title":"remember the eggs"}]%

Finish task

$ curl -X PUT http://localhost:8080/api/task/2/finish
  {"id":2,"title":"remember the eggs","finishedAt":"2017-06-13T16:25:55Z","createdAt":"2017-06-13T16:22:52Z","updatedAt":"2017-06-13T16:25:55Z"}%

Get task(s)

$ curl -XGET http://localhost:8080/api/task/2
  {"id":2,"title":"remember the milk","finishedAt":"","createdAt":"2017-06-13T16:22:52Z","updatedAt":"2017-06-13T16:22:52Z"}%
$ curl -XGET http://localhost:8080/api/tasks | jq
  [
    {
      "id": 2,
      "title": "remember the milk",
      "finishedAt": "",
      "createdAt": "2017-06-13T16:22:52Z",
      "updatedAt": "2017-06-13T16:22:52Z"
    },
    {
      "id": 1,
      "title": "task title",
      "finishedAt": "",
      "createdAt": "2017-06-13T15:51:42Z",
      "updatedAt": "2017-06-13T15:51:42Z"
    }
  ]

Subscribe task count

$ curl -XGET -H 'Content-Type:text/event-stream' http://localhost:8080/api/task-count
data:{"count":3}

data:{"count":4}

Running the applications

Running docker containers.

(spring5-kotlin-application) $ sh ./setup/sh

After running docker containers, you can confirm api response via API of HTTP and gRPC gateway.

via API of HTTP

$ curl -XGET http://localhost:8080/api/task/1
  {"id":1,"title":"task title","finishedAt":"","createdAt":"2017-06-13T15:51:42Z","updatedAt":"2017-06-13T15:51:42Z"}%

via gRPC gateway

$ curl -XPOST \
           http://localhost:8081/grpcgateway/task \
           -H 'Content-type: application/json' \
           -d '{"task_id": 1}'
  {"task_id":1,"title":"task title","createdAt":"49797-04-11T09:50:00.000Z","updatedAt":"49797-04-11T09:50:00.000Z"}%
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].