Code Monkey home page Code Monkey logo

basics's Introduction

Basics

This is a collection of sample projects in several languages I like to work with. The example shows a basic version of a REST service that allows adding, listing and retrieving a simple Customer record. The Scala version also offers a gRPC api.

Setup

Create a Mysql database, e.g. using Docker.

see https://spring.io/guides/gs/accessing-data-mysql

create database for demo:

docker exec -it some-mysql bash

mysql --password
# password = my-secret-pw

create database db_example;
create user 'springuser'@'%' identified by 'ThePassword';
grant all on db_example.* to 'springuser'@'%';

Test

The implementation in each language offers the following endpoints:

Endpoint Description
GET /customers/all Json list of all customers
GET /customers/{id} Query customer by uuid
POST /customers Save a new customer

Save a customer

curl -v -d '{"name":"i1", "email": "a@com"}' \
-H 'Content-Type: application/json' \
-X POST localhost:8080/customers

Get customer by id

curl -v localhost:8080/customers/4303cdaa-1504-4271-a614-1106daa2e83

List all customers

curl -v localhost:8080/customers/

Note: the Kotlin version currently requires a trailing / when POSTing a new customer.

Actuator

The actuator works for Java and Kotlin and shows documentation for each endpoint

curl http://localhost:8080/api/actuator/mappings
# endpoints, add /api to get the full url
curl http://localhost:8080/api/actuator/mappings |jq | grep predicate

basics's People

Contributors

jvermeir avatar

Watchers

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