feat: refactor server with shelf_static, return JSON responses, add API docs

This commit is contained in:
dmit.b
2026-05-09 09:12:44 +03:00
parent cd85f5f2db
commit 97db1b6b58
46 changed files with 172153 additions and 24 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ class GeoRoutes {
}
Future<Response> _updatePosition(Request request, String login) async {
final id = int.parse(request.url.queryParameters['id']!);
final id = request.url.queryParameters['id']!;
final body = await request.readAsString();
final data = jsonDecode(body);
@@ -26,7 +26,7 @@ class GeoRoutes {
await database.updatePosition(id, x, y);
await database.createLog(login, 'Updated position id=$id');
return Response(200);
return Response(200, body: jsonEncode({'message': 'Position updated'}), headers: {'Content-Type': 'application/json'});
}
Future<Response> _createShare(Request request, String login) async {
@@ -43,6 +43,6 @@ class GeoRoutes {
return Response(201, body: jsonEncode({
'geo_id': position.id,
'share_id': shareId
}));
}), headers: {'Content-Type': 'application/json'});
}
}