C++ REST server module#

namespace server#

Namespace including the API Eigen Example Server implemented in C++.

class RestServer#

Class containing the server logic.

Public Functions

RestServer()#

Construct a new Rest Server object.

~RestServer()#

Destroy the Rest Server object.

void serve(const int port = 18080, const bool async = false, const crow::LogLevel logLevel = crow::LogLevel::Info)#

Method for serving our application.

Parameters:
  • port – the port in which we want to server our app. Default: 18080.

  • async – whether we want to run application asynchronously or not. Default: false.

  • logLevel – the logging level of our server. Default: Info.

inline crow::SimpleApp &get_app()#

Get the app object.

Returns:

crow::SimpleApp&

Private Functions

void vector_resource_endpoints()#

Method defining the “Vectors” Resource endpoints.

void matrix_resource_endpoints()#

Method defining the “Matrices” Resource endpoints.

void vector_operations_endpoints()#

Method defining the “Vectors” operations endpoints.

void matrix_operations_endpoints()#

Method defining the “Matrices” operations endpoints.

crow::response add_vectors(int id1, int id2)#

Method in charge of retrieving the Vector resources from the DB and adding them.

Parameters:
  • id1 – - the id of the first Vector.

  • id2 – - the id of the second Vector.

Returns:

crow::response

crow::response multiply_vectors(int id1, int id2)#

Method in charge of retrieving the Vector resources from the DB and performing their dot product.

Parameters:
  • id1 – - the id of the first Vector.

  • id2 – - the id of the second Vector.

Returns:

crow::response

crow::response add_matrices(int id1, int id2)#

Method in charge of retrieving the Matrix resources from the DB and adding them.

Parameters:
  • id1 – - the id of the first Matrix.

  • id2 – - the id of the second Matrix.

Returns:

crow::response

crow::response multiply_matrices(int id1, int id2)#

Method in charge of retrieving the Matrix resources from the DB and multiplying them.

Parameters:
  • id1 – - the id of the first Matrix.

  • id2 – - the id of the second Matrix.

Returns:

crow::response

Private Members

db::RestDb _db#

The server’s DB.

crow::SimpleApp _app#

The server CROW application.