mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
add TLSConfig on redis configuration #1515
Former-commit-id: 3ce4a43185c7b6b5250f49483d7d229ea9dd1670
This commit is contained in:
@@ -974,12 +974,14 @@ func (api *APIBuilder) Favicon(favPath string, requestPath ...string) *Route {
|
||||
// OnErrorCode registers a handlers chain for this `Party` for a specific HTTP status code.
|
||||
// Read more at: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
||||
// Look `OnAnyErrorCode` too.
|
||||
func (api *APIBuilder) OnErrorCode(statusCode int, handlers ...context.Handler) {
|
||||
api.handle(statusCode, "", "/", handlers...)
|
||||
func (api *APIBuilder) OnErrorCode(statusCode int, handlers ...context.Handler) (routes []*Route) {
|
||||
routes = append(routes, api.handle(statusCode, "", "/", handlers...))
|
||||
|
||||
if api.relativePath != "/" {
|
||||
api.handle(statusCode, "", "/{tail:path}", handlers...)
|
||||
routes = append(routes, api.handle(statusCode, "", "/{tail:path}", handlers...))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ClientErrorCodes holds the 4xx Client errors.
|
||||
@@ -1083,10 +1085,12 @@ func StatusText(code int) string {
|
||||
// OnAnyErrorCode registers a handlers chain for all error codes
|
||||
// (4xxx and 5xxx, change the `ClientErrorCodes` and `ServerErrorCodes` variables to modify those)
|
||||
// Look `OnErrorCode` too.
|
||||
func (api *APIBuilder) OnAnyErrorCode(handlers ...context.Handler) {
|
||||
func (api *APIBuilder) OnAnyErrorCode(handlers ...context.Handler) (routes []*Route) {
|
||||
for _, statusCode := range append(ClientErrorCodes, ServerErrorCodes...) {
|
||||
api.OnErrorCode(statusCode, handlers...)
|
||||
routes = append(routes, api.OnErrorCode(statusCode, handlers...)...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Layout overrides the parent template layout with a more specific layout for this Party.
|
||||
|
||||
@@ -97,6 +97,14 @@ func (api *APIContainer) convertHandlerFuncs(relativePath string, handlersFn ...
|
||||
return handlers
|
||||
}
|
||||
|
||||
func fixRouteInfo(route *Route, handlersFn []interface{}) {
|
||||
// Fix main handler name and source modified by execution rules wrapper.
|
||||
route.MainHandlerName, route.MainHandlerIndex = context.MainHandlerName(handlersFn...)
|
||||
if len(handlersFn) > route.MainHandlerIndex {
|
||||
route.SourceFileName, route.SourceLineNumber = context.HandlerFileLineRel(handlersFn[route.MainHandlerIndex])
|
||||
}
|
||||
}
|
||||
|
||||
// Handler receives a function which can receive dependencies and output result
|
||||
// and returns a common Iris Handler, useful for Versioning API integration otherwise
|
||||
// the `Handle/Get/Post...` methods are preferable.
|
||||
@@ -134,13 +142,7 @@ func (api *APIContainer) Done(handlersFn ...interface{}) {
|
||||
func (api *APIContainer) Handle(method, relativePath string, handlersFn ...interface{}) *Route {
|
||||
handlers := api.convertHandlerFuncs(relativePath, handlersFn...)
|
||||
route := api.Self.Handle(method, relativePath, handlers...)
|
||||
|
||||
// Fix main handler name and source modified by execution rules wrapper.
|
||||
route.MainHandlerName, route.MainHandlerIndex = context.MainHandlerName(handlersFn...)
|
||||
if len(handlersFn) > route.MainHandlerIndex {
|
||||
route.SourceFileName, route.SourceLineNumber = context.HandlerFileLineRel(handlersFn[route.MainHandlerIndex])
|
||||
}
|
||||
|
||||
fixRouteInfo(route, handlersFn)
|
||||
return route
|
||||
}
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@ type Party interface {
|
||||
// OnErrorCode registers a handlers chain for this `Party` for a specific HTTP status code.
|
||||
// Read more at: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
||||
// Look `OnAnyErrorCode` too.
|
||||
OnErrorCode(statusCode int, handlers ...context.Handler)
|
||||
OnErrorCode(statusCode int, handlers ...context.Handler) []*Route
|
||||
// OnAnyErrorCode registers a handlers chain for all error codes
|
||||
// (4xxx and 5xxx, change the `ClientErrorCodes` and `ServerErrorCodes` variables to modify those)
|
||||
// Look `OnErrorCode` too.
|
||||
OnAnyErrorCode(handlers ...context.Handler)
|
||||
OnAnyErrorCode(handlers ...context.Handler) []*Route
|
||||
|
||||
// Party groups routes which may have the same prefix and share same handlers,
|
||||
// returns that new rich subrouter.
|
||||
|
||||
Reference in New Issue
Block a user