READMESource: main@83b9a4a5
简体中文
这是什么
my-first-plugin 是一个最小的 DSH 插件骨架:它只做一件事——在 Web 服务上注册一个 GET /_dsh/hello 路由,返回一行 JSON。用来验证插件从安装到运行整条链路是否打通。
安装
dsh plugin --profile web add github:LWH13345412221/my-first-plugin
然后在 profile 的 cordis.patch.yml 里加上这一行(插件自带 cordis.patch.yml,也可以直接把它 insert 进你的层栈):
- insert:
- id: my-first-plugin
name: 'my-first-plugin'
重启 dsh web 后生效。
验证
curl http://127.0.0.1:<web-port>/_dsh/hello
期望返回:
{"ok":true,"value":{"hello":"from my-first-plugin","time":"..."}}
目录结构
my-first-plugin/
├── lib/index.js # 宿主半侧:注册 /_dsh/hello 路由
├── cordis.patch.yml # bundle 挂载声明
├── package.json # 包信息(声明 dsh.bundle)
└── assets/banner.svg # README 横幅
继续扩展
- 想加界面:在
package.json里加dsh.client.inject与dsh.client.platform: "web",并提供lib/client.js; - 想加配置:在
cordis.patch.yml的 entry 上加config字段; - 想加接口:在
apply()里多注册几个webServer.register路由。
English
What is this
my-first-plugin is a minimal DSH plugin skeleton. It does exactly one thing: registers a GET /_dsh/hello route on the web server and returns a small JSON payload — enough to prove the whole install-to-runtime path works.
Install
dsh plugin --profile web add github:LWH13345412221/my-first-plugin
Then add the entry to your profile's cordis.patch.yml (the plugin ships its own patch, or insert it into your layer stack):
- insert:
- id: my-first-plugin
name: 'my-first-plugin'
Restart dsh web to load it.
Verify
curl http://127.0.0.1:<web-port>/_dsh/hello
Expected:
{"ok":true,"value":{"hello":"from my-first-plugin","time":"..."}}
Layout
my-first-plugin/
├── lib/index.js # host half: registers the /_dsh/hello route
├── cordis.patch.yml # bundle mount declaration
├── package.json # declares dsh.bundle
└── assets/banner.svg # README banner
Next steps
- Add a UI: declare
dsh.client.inject+dsh.client.platform: "web"and shiplib/client.js; - Add config: put a
configblock on the entry incordis.patch.yml; - Add endpoints: register more
webServer.registerroutes insideapply().
Part of the dsh-plugin ecosystem · MIT License
No comments yet. Be the first to write one.