-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API 的插件框架 #413
Draft
Cirn09
wants to merge
14
commits into
qd-today:master
Choose a base branch
from
Cirn09:api-v3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+786
−29
Draft
API 的插件框架 #413
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
560661b
装饰器风格的 API plugin 框架
Cirn09 0e6de95
API examples
Cirn09 bcebbaf
API plugin 框架更新
Cirn09 7de14c1
api://api/xx -> api://v1/xx
Cirn09 4522323
Update Error message display
a76yyyy 90d549d
Fix bug from codeQL
a76yyyy 8002a66
强制 JSON 的 API 框架
Cirn09 e255dea
BodyArgument 自动解码
Cirn09 8a90d67
Merge branch 'master' into api-v3
a76yyyy ad3579e
更新 BodyArgument 的自动解码
Cirn09 48d1862
在 jinja 中加入 json 相关函数
Cirn09 f09aacf
Merge branch 'api-v3' of https://github.com/Cirn09/qiandao into api-v3
Cirn09 0c97382
合并时的遗留问题
Cirn09 abc6e34
Merge branch 'master' into api-v3
a76yyyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该没必要进行转义,因为 Content-Type 已经设置为
application/json
了更进一步,API 的返回内容默认为
text/plain
吧,避免 API 作者忘记转义(比如我);bytes
类型则application/octet-stream
;JSONapplication/json
。应该没有 API 需要使用其他类型的需求,所以就不用允许 API 自己设置 Content-Type 了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我的建议是默认返回JSON格式的
code,message,data
信息There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
既然是api就一步到位,规范一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样设计的话,我觉得对应的系统对 JSON respond 的处理能力需要增强,目前系统对返回内容好像只支持正则匹配。
思考了一下好像不难实现,提供一个 respond content 的魔法变量和一个 JSON 函数应该就可以了,比如
{{ json_parse(content)['code'] }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在的模式:
新UI: 类型(下拉: 简单, 正则(和旧版兼容), 代码), 来源(下拉: respond.[content, header, status]), 变量名, 规则, 结果
类型为代码时则不显示来源,可以使用
{{ respond.content }}
之类的There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有看到新UI的界面?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在写了.jpg,先把方案写下来讨论一下