Home

Awesome

Example-CRUD Build Status

A complete example of a "CRUD" service (UserService) built with Oat++.

In this example:

More about Oat++:

Overview

This project is using the following oatpp modules:

Project layout

|- CMakeLists.txt                        // projects CMakeLists.txt
|- sql/                                  // SQL migration scripts for SQLite database
|- src/
|   |
|   |- controller/                       // Folder containing REST Controllers (UserController)
|   |- db/                               // Folder containing the database client
|   |- dto/                              // DTOs are declared here
|   |- service/                          // Service business logic classes (UserService)
|   |- AppComponent.hpp                  // Service config
|   |- DatabaseComponent.hpp             // Database config
|   |- SwaggerComponent.hpp              // Swagger-UI config
|   |- App.cpp                           // main() is here
|
|- test/                                 // test folder
|- utility/install-oatpp-modules.sh      // utility script to install required oatpp-modules.

Build and Run

Using CMake

Pre Requirements

Note: You may run utility/install-oatpp-modules.sh script to install required oatpp modules.

Build Project
$ mkdir build && cd build
$ cmake ..
$ make 
$ ./crud-exe        # - run application.

In Docker

$ docker build -t example-crud .
$ docker run -p 8000:8000 -t example-crud

Endpoints

HTML

HTTP MethodURLDescription
GEThttp://localhost:8000/Root page
GEThttp://localhost:8000/swagger/uiSwagger UI page

User Service

HTTP MethodURLDescription
POSThttp://localhost:8000/usersCreate new User
PUThttp://localhost:8000/users/{userId}Update User by ID
GEThttp://localhost:8000/users/{userId}Get User by ID
DELETEhttp://localhost:8000/users/{userId}Delete User by ID
GEThttp://localhost:8000/users/offset/{offset}/limit/{limit}Get All Users with Paging