Exhibition-RestServer: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 7: | Zeile 7: | ||
= Features = | = Features = | ||
* The communication between the dev-app (as a client) and restserver is done via HTTP in the REpresentational State Transfer design pattern. | * The communication between the dev-app (as a client) and restserver is done via HTTP in the REpresentational State Transfer design pattern. | ||
* The program of the restserver is a static piece of software, the customizing is done with configuration in some files. | * The program of the restserver 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 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. | * 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. | ||
Version vom 1. August 2021, 12:48 Uhr
Links
Introduction
The restserver 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 restserver is done via HTTP in the REpresentational State Transfer design pattern.
- The program of the restserver 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 Exhibition 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;"