1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 09:57:01 +00:00

add some api helpers

This commit is contained in:
kataras
2022-05-05 02:46:15 +03:00
parent 4a43cd1fbb
commit 10c1542daf
5 changed files with 56 additions and 1 deletions

View File

@@ -318,6 +318,20 @@ func (p *prefixedDir) Open(name string) (http.File, error) {
return p.fs.Open(name)
}
type partyConfiguratorMiddleware struct {
handlers []Handler
}
func (p *partyConfiguratorMiddleware) Configure(r Party) {
r.Use(p.handlers...)
}
// ConfigureMiddleware is a PartyConfigurator which can be used
// as a shortcut to add middlewares on Party.PartyConfigure("/path", WithMiddleware(handler), new(example.API)).
func ConfigureMiddleware(handlers ...Handler) router.PartyConfigurator {
return &partyConfiguratorMiddleware{handlers: handlers}
}
var (
// Compression is a middleware which enables
// writing and reading using the best offered compression.