Skip to content

Commit

Permalink
Merge pull request #753 from trheyi/main
Browse files Browse the repository at this point in the history
Fix PublicRoot bug and get Sid from request
  • Loading branch information
trheyi authored Sep 25, 2024
2 parents 0ea4009 + 896e52a commit 6c6aaad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sui/api/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

raw, err := jsoniter.Marshal(process.Args[5])
Expand Down
8 changes: 8 additions & 0 deletions sui/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ func NewRequestContext(c *gin.Context) (*Request, int, error) {

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{
File: file,
context: c,
Request: &core.Request{
Sid: sid,
Method: c.Request.Method,
Query: c.Request.URL.Query(),
Body: body,
Expand Down
4 changes: 3 additions & 1 deletion sui/core/sui.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ func (sui *DSL) PublicRoot(data map[string]interface{}) (string, error) {

// Merge the data
for k, v := range sessionData {
data[k] = v
if _, ok := data[k]; !ok {
data[k] = v
}
}

vars := map[string]interface{}{"$session": data}
Expand Down

0 comments on commit 6c6aaad

Please sign in to comment.