Merge pull request #753 from trheyi/main
Fix PublicRoot bug and get Sid from request
This commit is contained in:
commit
6c6aaad058
3 changed files with 12 additions and 2 deletions
|
|
@ -194,7 +194,7 @@ func TemplateRender(process *process.Process) interface{} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r := core.Request{Theme: opt["theme"], Locale: opt["locale"]}
|
r := core.Request{Theme: opt["theme"], Locale: opt["locale"], Sid: process.Sid}
|
||||||
if process.NumOfArgs() > 5 {
|
if process.NumOfArgs() > 5 {
|
||||||
|
|
||||||
raw, err := jsoniter.Marshal(process.Args[5])
|
raw, err := jsoniter.Marshal(process.Args[5])
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,18 @@ func NewRequestContext(c *gin.Context) (*Request, int, error) {
|
||||||
|
|
||||||
path := strings.TrimSuffix(c.Request.URL.Path, ".sui")
|
path := strings.TrimSuffix(c.Request.URL.Path, ".sui")
|
||||||
|
|
||||||
|
sid := ""
|
||||||
|
if v, has := c.Get("__sid"); has {
|
||||||
|
if s, ok := v.(string); ok {
|
||||||
|
sid = s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &Request{
|
return &Request{
|
||||||
File: file,
|
File: file,
|
||||||
context: c,
|
context: c,
|
||||||
Request: &core.Request{
|
Request: &core.Request{
|
||||||
|
Sid: sid,
|
||||||
Method: c.Request.Method,
|
Method: c.Request.Method,
|
||||||
Query: c.Request.URL.Query(),
|
Query: c.Request.URL.Query(),
|
||||||
Body: body,
|
Body: body,
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,9 @@ func (sui *DSL) PublicRoot(data map[string]interface{}) (string, error) {
|
||||||
|
|
||||||
// Merge the data
|
// Merge the data
|
||||||
for k, v := range sessionData {
|
for k, v := range sessionData {
|
||||||
data[k] = v
|
if _, ok := data[k]; !ok {
|
||||||
|
data[k] = v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vars := map[string]interface{}{"$session": data}
|
vars := map[string]interface{}{"$session": data}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue