Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Use protobuf messages as regular oatpp DTOs

License

Notifications You must be signed in to change notification settings

einblick-ai/oatpp-protobuf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oatpp-protobuf

Alpha
Since oatpp 1.2.0

Protobuf messages integration with oatpp object-mapping framework.

Now you can use protobuf messages as regular oatpp DTOs!

More about Oat++:

Usage

Let's say we have a .proto file:

syntax = "proto3";

message User {
    enum Role {
        ADMIN = 0;
        GUEST = 1;
    }
    string name = 1;
    Role role = 2;
}

In Endpoint

ENDPOINT("POST", "createUser", createUser, 
         BODY_DTO(oatpp::protobuf::Object<User>, user)) 
{
  auto name = user->name();
  auto role = user->role();
  ...
  return createResponse(Status::CODE_200, "OK");
}
ENDPOINT("GET", "getUser", getUser) 
{
  oatpp::protobuf::Object<User> user = std::make_shared<User>();
  user->set_name("Ivan");
  user->set_role(User_Role_GUEST);
  return createDtoResponse(Status::CODE_200, user);
}

Output:

{
  "name": "Ivan",
  "role": "GUEST"
}

About

Use protobuf messages as regular oatpp DTOs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 72.2%
  • CMake 23.6%
  • Shell 4.2%