MCPcopy Create free account
hub / github.com/kataras/iris / HandleMany

Method HandleMany

core/router/api_builder.go:589–610  ·  view source on GitHub ↗

HandleMany works like `Handle` but can receive more than one paths separated by spaces and returns always a slice of *Route instead of a single instance of Route. It's useful only if the same handler can handle more than one request paths, otherwise use `Party` which can handle many paths with diff

(methodOrMulti string, relativePathorMulti string, handlers ...context.Handler)

Source from the content-addressed store, hash-verified

587//
588// app.HandleMany("GET POST", "/path", handler)
589func (api *APIBuilder) HandleMany(methodOrMulti string, relativePathorMulti string, handlers ...context.Handler) (routes []*Route) {
590 // at least slash
591 // a space
592 // at least one other slash for the next path
593 paths := splitPath(relativePathorMulti)
594 methods := splitMethod(methodOrMulti)
595 for _, p := range paths {
596 if p != "" {
597 for _, method := range methods {
598 if method == "" {
599 method = "ANY"
600 }
601 if method == "ANY" || method == "ALL" {
602 routes = append(routes, api.Any(p, handlers...)...)
603 continue
604 }
605 routes = append(routes, api.Handle(method, p, handlers...))
606 }
607 }
608 }
609 return
610}
611
612// HandleDir registers a handler that serves HTTP requests
613// with the contents of a file system (physical or embedded).

Callers 1

AnyMethod · 0.95

Calls 4

AnyMethod · 0.95
HandleMethod · 0.95
splitPathFunction · 0.85
splitMethodFunction · 0.85

Tested by

no test coverage detected