mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(apigateway): support _custom_id_ tag on create-rest-api (#644)
When create-rest-api includes tags: {"_custom_id_": "ALIAS"}, use the
tag value as the API ID instead of the random 10-char shortId. This
matches LocalStack behavior and allows callers to invoke the API at
/execute-api/ALIAS/{stage}/{path} without knowing the auto-generated ID.
Also include tags in the create/get REST API response.
Fixes #636
This commit is contained in:
1 parent
160a0a35d6
commit
cb0a82b749
3 files changed
+49
-1
No files matched your search
@@ -1028,6 +1028,11 @@ public class ApiGatewayController {
|
||||
node.put("name", api.getName());
|
||||
if (api.getDescription() != null) node.put("description", api.getDescription());
|
||||
node.put("createdDate", api.getCreatedDate());
|
||||
if (api.getTags() != null && !api.getTags().isEmpty()) {
|
||||
ObjectNode tagsNode = objectMapper.createObjectNode();
|
||||
api.getTags().forEach(tagsNode::put);
|
||||
node.set("tags", tagsNode);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,11 +82,19 @@ public class ApiGatewayService {
|
||||
String name = (String) request.get("name");
|
||||
String description = (String) request.get("description");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> tags = request.get("tags") instanceof Map<?, ?> m
|
||||
? (Map<String, String>) m : new HashMap<>();
|
||||
|
||||
String customId = tags.get("_custom_id_");
|
||||
String apiId = (customId != null && !customId.isBlank()) ? customId : shortId(10);
|
||||
|
||||
RestApi api = new RestApi();
|
||||
api.setId(shortId(10));
|
||||
api.setId(apiId);
|
||||
api.setName(name);
|
||||
api.setDescription(description);
|
||||
api.setCreatedDate(System.currentTimeMillis() / 1000L);
|
||||
api.setTags(tags);
|
||||
|
||||
apiStore.put(apiKey(region, api.getId()), api);
|
||||
|
||||
|
||||
Reference in new issue
Block a user