Skip to content
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

feat: Add hook interceptor & add cmd & some fix #24

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

IRONICBo
Copy link
Collaborator

🔍 What type of PR is this?

/kind feature

👀 What this PR does / why we need it:

Add hook interceptor & add cmd & some fix

  • hook interceptor: Use trie to store and match url pattern and hooks.

🅰 Which issue(s) this PR fixes:

Fixes # #23, #22, #21

@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 28, 2023
}

func (h MailHook) Pattern() string {
return "/api/v1/register/email/code"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be set as a constant?

Copy link
Collaborator Author

@IRONICBo IRONICBo Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cubxxw I define a interface to set url binding in hooks:

type Hook interface {
	Pattern() string
	BeforeRun(c *gin.Context)
	AfterRun(c *gin.Context)
}

The custom hooks are forced to implement these properties, but the properties cannot be defined inside the interface, so I defined Pattern as a method and returned Pattern for the hook's registry to bind Pattern and execute the function.

Regarding the rationality of the design, I think we can discuss it in the meeting.

@cubxxw cubxxw merged commit 9301208 into openimsdk:main Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
Status: Done
2 participants