Former-commit-id: d8d73b3e1b713af9bf7b4712121324079ede6a41
This commit is contained in:
Gerasimos (Makis) Maropoulos 2018-11-28 23:20:08 +02:00
parent 1843a7d1f1
commit 8b85b602df
4 changed files with 20 additions and 21 deletions

View File

@ -31,6 +31,8 @@ func main() {
// same as navigating to "http://localhost:8080/invisible/iris" when /change has being invoked and route state changed
// from "offline" to "online"
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")
})

View File

@ -3428,7 +3428,7 @@ func (ctx *context) TransactionsSkipped() bool {
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
// 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
backupHandlers := ctx.Handlers()[0:]
backupPos := ctx.HandlerIndex(-1)
backupHandlers := ctx.handlers[0:]
backupPos := ctx.currentHandlerIndex
req := ctx.request
// backup the request path information
backupPath := ctx.Path()
backupMethod := ctx.Method()
backupPath := req.URL.Path
backupMethod := req.Method
// 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'
req.RequestURI = path
req.URL.Path = path
req.Method = method
// [values stays]
// reset handlers
ctx.handlers = ctx.handlers[0:0]
ctx.currentHandlerIndex = 0
// execute the route from the (internal) context router
// this way we keep the sessions and the values
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
req.RequestURI = backupPath
req.URL.Path = backupPath
req.Method = backupMethod
// don't fill the values in order to be able to communicate from and to.
// // fill the values as they were before
// backupValues.Visit(func(key string, value interface{}) {
// ctx.Values().Set(key, value)
// })
// set back the old handlers and the last known index
ctx.handlers = backupHandlers
ctx.currentHandlerIndex = backupPos
}
// RouteExists reports whether a particular route exists

View File

@ -733,10 +733,10 @@ func checkIfRange(ctx context.Context, etagEmptyOrStrongMatch func(ifRangeValue
return condFalse
}
const indexPage = "/index.html"
// name is '/'-separated, not filepath.Separator.
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 .../
// can't use Redirect() because that would make the path absolute,
// which would be a problem running under StripPrefix

2
go.sum
View File

@ -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/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/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
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/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/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
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/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=