提供 tinystruct Java 框架开发指导,覆盖路由、测试、持久化与服务端能力。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "tinystruct-patterns" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/tinystruct-patterns/SKILL.md 2. 保存为 ~/.claude/skills/tinystruct-patterns/SKILL.md 3. 装好后重载技能,告诉我可以用了
请基于 tinystruct 演示如何创建一个 Application 类,并定义两个使用 @Action 映射的路由:GET /health 和 POST /users。请给出完整 Java 示例,并说明 ActionRegistry 需要如何注册。
返回可运行的 tinystruct 应用骨架代码,包含 Application、Action 路由实现与注册说明。
我有一个 tinystruct 的 Action,用于处理用户创建请求。请帮我设计单元测试方案,包含成功、参数缺失、JSON 格式错误三种场景,并给出测试代码示例。
返回针对 tinystruct Action 的测试思路与示例代码,覆盖正常与异常分支。
请用 tinystruct 说明如何基于 AbstractData 定义一个 User 实体,完成保存与查询,并在用户创建后触发事件,再通过 SSE 将结果推送给前端。请给出关键代码结构。
返回结合 AbstractData、事件系统与 SSE 的实现方案和核心代码示例。
Architecture and implementation patterns for building modules with the tinystruct Java framework – a lightweight, high-performance framework that treats CLI and HTTP as equal citizens, requiring no main() method and minimal configuration.
CLI and HTTP are equal citizens. Every method annotated with @Action should ideally be runnable from both a terminal and a web browser without modification. This "dual-mode" capability is the core design philosophy of tinystruct.
Application modules by extending AbstractApplication.@Action.Context.Builder and Builders components.AbstractData POJOs.generate command.URLRequest and HTTPHandler.application.properties.The tinystruct framework treats any method annotated with @Action as a routable endpoint for both terminal and web environments. Applications are created by extending AbstractApplication, which provides core lifecycle hooks like init() and access to the request Context.
Routing is handled by the ActionRegistry, which automatically maps path segments to method arguments and injects dependencies. For data-only services, the native Builder and Builders components should be used for JSON serialization to maintain a zero-dependency footprint. The database layer uses AbstractData POJOs paired with XML mapping files for CRUD operations without external ORM libraries.
public class MyService extends AbstractApplication {
@Override
public void init() {
this.setTemplateRequired(false); // Disable .view lookup for data/API apps
}
@Override public String version() { return "1.0.0"; }
@Action("greet")
public String greet() {
return "Hello from tinystruct!";
}
// Path parameter: GET /?q=greet/James OR bin/dispatcher greet/James
@Action("greet")
public String greet(String name) {
return "Hello, " + name + "!";
}
}
@Action(value = "login", mode = Mode.HTTP_POST)
public String doLogin(Request<?, ?> request) throws ApplicationException {
request.getSession().setAttribute("userId", "42");
return "Logged in";
}
import org.tinystruct.data.component.Builder;
import org.tinystruct.data.component.Builders;
@Action("api/data")
public String getData() throws ApplicationException {
Builders dataList = new Builders();
Builder item = new Builder();
item.put("id", 1);
item.put("name", "James");
dataList.add(item);
Builder response = new Builder();
response.put("status", "success");
response.put("data", dataList);
return response.toString(); // {"status":"success","data":[{"id":1,"name":"James"}]}
}
import org.tinystruct.http.SSEPushManager;
@Action("sse/connect")
public String connect() {
return "{\"type\":\"connect\",\"message\":\"Connected to SSE\"}";
}
// Push to a specific client
String sessionId = getContext().getId();
Builder msg = new Builder();
msg.put("text", "Hello, user!");
SSEPushManager.getInstance().push(sessionId, msg);
// Broadcast to all
// Broadcast to all
SSEPushManager.getInstance().broadcast(msg);
import org.tinystruct.data.FileEntity;
…
帮助你部署和维护家庭网络中的 Pi-hole 广告拦截与 DNS 服务
帮助生成或审查设计系统,检查视觉一致性并评审样式相关改动。
帮助团队快速制定项目规范示例,统一协作流程与文档标准
帮助团队按 HIPAA 要求处理医疗隐私、安全合规与泄露应对事项
提供现代 Perl 5.36+ 惯用法与最佳实践,帮助编写稳健且易维护的应用。
帮助你设计并实现 F# 单元、属性与集成测试的最佳实践
连接 Tiny ERP,统一查询和处理商品、库存、订单与应收应付数据
帮助用户进行 JSON 的生成、校验、格式化与结构化处理。
通过四个示例工具演示 MCP 服务的参数设计、结构化输出与错误处理
帮助开发者用 Node/TypeScript 快速构建符合规范的 MCP 服务器与工具能力
提供 FastAPI 项目结构、鉴权、事务分层与测试的最佳实践指导
帮助开发者系统学习 Spring AI 与 MCP,构建智能体与大模型应用项目。