Exhibition-RestServer: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
|||
Zeile 70: | Zeile 70: | ||
sql: "DELETE FROM persons WHERE person_id=:id;" | sql: "DELETE FROM persons WHERE person_id=:id;" | ||
</pre> | </pre> | ||
= Installation = | |||
The rest_server must be installed on a backend server. During development that can be localhost. | |||
== Preparation == |
Version vom 6. August 2021, 01:32 Uhr
Links
Introduction
The rest_server is a sub project of the dev-app implementing a backend for managing the data storage in a MySql database.
Features
- The communication between the dev-app (as a client) and rest_server is done via HTTP in the REpresentational State Transfer design pattern.
- The program of the rest_server is a static piece of software written in Dart, the customizing is done with configuration in some files. This sub project does not have dependencies on Flutter.
- The server is a multithreaded HTTP server, the number of threads (Dart isolates) may be configured.
- The Sql statements must be specified with "named parameters". But the dart module mysqldb cannot handle named parameters. Therefore the statements will be converted into "positional parameters" automatically.
Configuration
Main Configuration
The main configuration is done by a yaml file:
--- # Example configuration file for the rest server. Created by rest_server. service: address: 0.0.0.0 port: 58031 dataDirectory: /tmp/unittest/data sqlDirectory: ${path.dirname(sqlFile)} threads: 1 watchDogPause: 60 # logFile: /var/log/local/exhibition.log trace: answerLength: 200 db: db: dbtest user: dbtest code: "TopSecret" host: localhost port: 3306 primaryTable: persons timeout: 30 traceDataLength: 200 clientSessionTimeout: 900
Sql Configuration
The SQL statements for each module must be specified in a yaml file.
Note: Normally this file is generated by the meta_tool from the metadata.
--- # SQL statements of the module "Persons": module: Persons list: type: list parameters: [] sql: select * from persons; byId: type: record parameters: [ ":id" ] sql: "select * from persons where person_id=:id;" update: type: update parameters: [":id", ":name", ":email", ":changedby"] sql: "UPDATE persons SET person_name=:name, person_email=:email, person_changed=NOW(), person_changedby=:changedby WHERE person_id=:id;" insert: type: insert parameters: [":name", ":email", ":createdby"] sql: "INSERT INTO persons(person_name, person_email, person_created, person_createdby) VALUES(:name, :email, NOW(), :createdby);" delete: type: delete parameters: [':id'] sql: "DELETE FROM persons WHERE person_id=:id;"
Installation
The rest_server must be installed on a backend server. During development that can be localhost.