Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Fault injection filter #330

Closed
mark4z opened this issue Dec 24, 2021 · 1 comment
Closed

Add Fault injection filter #330

mark4z opened this issue Dec 24, 2021 · 1 comment
Labels
good first issue Good for newcomers

Comments

@mark4z
Copy link
Member

mark4z commented Dec 24, 2021

What would you like to be added:
A Fault injection filter should provide configurable error injection capabilities, such as delay, error local reply. it is best to have more detailed routing-based configuration capabilities

Why is this needed:
Because this is the ability that is required in the testing phase

How to:
A simple example :
pkg/filter/authority/authority.go

ctxc.SendLocalReply will be useful in this new filter.

func (f *Filter) Decode(c *http.HttpContext) filter.FilterStatus {
	for _, r := range f.cfg.Rules {
		item := c.GetClientIP()
		if r.Limit == App {
			item = c.GetApplicationName()
		}

		result := passCheck(item, r)
		if !result {
			c.SendLocalReply(nh.StatusForbidden, constant.Default403Body)
			return filter.Stop
		}
	}
	return filter.Continue
}
@mark4z mark4z changed the title Fault injection filter Add Fault injection filter Dec 24, 2021
@mark4z mark4z added the good first issue Good for newcomers label Dec 24, 2021
@mark4z
Copy link
Member Author

mark4z commented Oct 15, 2023

close via #571

@mark4z mark4z closed this as completed Oct 15, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant