Change /share to create geoposition, /geo?id to update by id
This commit is contained in:
@@ -29,19 +29,30 @@ class GeoRoutes {
|
||||
}
|
||||
|
||||
Future<Response> _updatePosition(Request request) async {
|
||||
final id = int.parse(request.url.queryParameters['id']!);
|
||||
final body = await request.readAsString();
|
||||
final data = jsonDecode(body);
|
||||
|
||||
final x = data['x'];
|
||||
final y = data['y'];
|
||||
|
||||
final position = await database.updatePosition(x, y);
|
||||
final position = await database.updatePosition(id, x, y);
|
||||
return Response(200, body: position.toJson());
|
||||
}
|
||||
|
||||
Future<Response> _createShare(Request request) async {
|
||||
final body = await request.readAsString();
|
||||
final data = jsonDecode(body);
|
||||
|
||||
final x = data['x'];
|
||||
final y = data['y'];
|
||||
|
||||
final position = await database.createPosition(x, y);
|
||||
final shareId = database.createShareId();
|
||||
|
||||
return Response(200, body: jsonEncode({'share_id': shareId}));
|
||||
return Response(201, body: jsonEncode({
|
||||
'geo_id': position.id,
|
||||
'share_id': shareId
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user