mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
Former-commit-id: d8d73b3e1b713af9bf7b4712121324079ede6a41
This commit is contained in:
parent
1843a7d1f1
commit
8b85b602df
|
@ -31,6 +31,8 @@ func main() {
|
||||||
// same as navigating to "http://localhost:8080/invisible/iris" when /change has being invoked and route state changed
|
// same as navigating to "http://localhost:8080/invisible/iris" when /change has being invoked and route state changed
|
||||||
// from "offline" to "online"
|
// from "offline" to "online"
|
||||||
ctx.Values().Set("from", "/execute") // values and session can be shared when calling Exec from a "foreign" context.
|
ctx.Values().Set("from", "/execute") // values and session can be shared when calling Exec from a "foreign" context.
|
||||||
|
// ctx.Exec("NONE", "/invisible/iris")
|
||||||
|
// or after "/change":
|
||||||
ctx.Exec("GET", "/invisible/iris")
|
ctx.Exec("GET", "/invisible/iris")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -3428,7 +3428,7 @@ func (ctx *context) TransactionsSkipped() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec calls the framewrok's ServeCtx
|
// Exec calls the framewrok's ServeHTTPC
|
||||||
// based on this context but with a changed method and path
|
// based on this context but with a changed method and path
|
||||||
// like it was requested by the user, but it is not.
|
// like it was requested by the user, but it is not.
|
||||||
//
|
//
|
||||||
|
@ -3461,41 +3461,36 @@ func (ctx *context) Exec(method string, path string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// backup the handlers
|
// backup the handlers
|
||||||
backupHandlers := ctx.Handlers()[0:]
|
backupHandlers := ctx.handlers[0:]
|
||||||
backupPos := ctx.HandlerIndex(-1)
|
backupPos := ctx.currentHandlerIndex
|
||||||
|
|
||||||
|
req := ctx.request
|
||||||
// backup the request path information
|
// backup the request path information
|
||||||
backupPath := ctx.Path()
|
backupPath := req.URL.Path
|
||||||
backupMethod := ctx.Method()
|
backupMethod := req.Method
|
||||||
// don't backupValues := ctx.Values().ReadOnly()
|
// don't backupValues := ctx.Values().ReadOnly()
|
||||||
|
|
||||||
// [values stays]
|
|
||||||
// reset handlers
|
|
||||||
ctx.SetHandlers(nil)
|
|
||||||
|
|
||||||
req := ctx.Request()
|
|
||||||
// set the request to be align with the 'againstRequestPath'
|
// set the request to be align with the 'againstRequestPath'
|
||||||
req.RequestURI = path
|
req.RequestURI = path
|
||||||
req.URL.Path = path
|
req.URL.Path = path
|
||||||
req.Method = method
|
req.Method = method
|
||||||
|
|
||||||
|
// [values stays]
|
||||||
|
// reset handlers
|
||||||
|
ctx.handlers = ctx.handlers[0:0]
|
||||||
|
ctx.currentHandlerIndex = 0
|
||||||
|
|
||||||
// execute the route from the (internal) context router
|
// execute the route from the (internal) context router
|
||||||
// this way we keep the sessions and the values
|
// this way we keep the sessions and the values
|
||||||
ctx.Application().ServeHTTPC(ctx)
|
ctx.Application().ServeHTTPC(ctx)
|
||||||
|
|
||||||
// set back the old handlers and the last known index
|
|
||||||
ctx.SetHandlers(backupHandlers)
|
|
||||||
ctx.HandlerIndex(backupPos)
|
|
||||||
// set the request back to its previous state
|
// set the request back to its previous state
|
||||||
req.RequestURI = backupPath
|
req.RequestURI = backupPath
|
||||||
req.URL.Path = backupPath
|
req.URL.Path = backupPath
|
||||||
req.Method = backupMethod
|
req.Method = backupMethod
|
||||||
|
|
||||||
// don't fill the values in order to be able to communicate from and to.
|
// set back the old handlers and the last known index
|
||||||
// // fill the values as they were before
|
ctx.handlers = backupHandlers
|
||||||
// backupValues.Visit(func(key string, value interface{}) {
|
ctx.currentHandlerIndex = backupPos
|
||||||
// ctx.Values().Set(key, value)
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RouteExists reports whether a particular route exists
|
// RouteExists reports whether a particular route exists
|
||||||
|
|
|
@ -733,10 +733,10 @@ func checkIfRange(ctx context.Context, etagEmptyOrStrongMatch func(ifRangeValue
|
||||||
return condFalse
|
return condFalse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const indexPage = "/index.html"
|
||||||
|
|
||||||
// name is '/'-separated, not filepath.Separator.
|
// name is '/'-separated, not filepath.Separator.
|
||||||
func serveFile(ctx context.Context, fs http.FileSystem, name string, redirect bool, showList bool, gzip bool) (string, int) {
|
func serveFile(ctx context.Context, fs http.FileSystem, name string, redirect bool, showList bool, gzip bool) (string, int) {
|
||||||
const indexPage = "/index.html"
|
|
||||||
|
|
||||||
// redirect .../index.html to .../
|
// redirect .../index.html to .../
|
||||||
// can't use Redirect() because that would make the path absolute,
|
// can't use Redirect() because that would make the path absolute,
|
||||||
// which would be a problem running under StripPrefix
|
// which would be a problem running under StripPrefix
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -23,6 +23,7 @@ github.com/gavv/monotime v0.0.0-20171021193802-6f8212e8d10d/go.mod h1:vmp8DIyckQ
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||||
|
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||||
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
|
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
|
||||||
|
@ -61,6 +62,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
|
||||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 h1:/vdW8Cb7EXrkqWGufVMES1OH2sU9gKVb2n9/1y5NMBY=
|
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 h1:/vdW8Cb7EXrkqWGufVMES1OH2sU9gKVb2n9/1y5NMBY=
|
||||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||||
|
|
Loading…
Reference in New Issue
Block a user