Skip to content

Commit

Permalink
add query
Browse files Browse the repository at this point in the history
  • Loading branch information
seefan committed Jan 3, 2021
1 parent 8a860e7 commit 2700d83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 4 additions & 0 deletions httpserver/http_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func newContext(writer http.ResponseWriter, request *http.Request) *HTTPContext
c.form = request.Form
}
}
if c.form == nil {
c.form = request.URL.Query()
}

return c
}

Expand Down
16 changes: 3 additions & 13 deletions httpserver/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,6 @@ func (h *HTTPServer) html(ht *template.HTML, err error, request *http.Request, w
return
}
if h.tpl != nil {
if len(request.Form) > 0 {
rspForm := make(map[string]interface{})
for k, v := range request.Form {
if len(v) == 0 {
rspForm[k] = ""
} else if len(v) == 1 {
rspForm[k] = v[0]
} else {
rspForm[k] = v
}
}
ht.Context["_form"] = rspForm
}
if err := h.tpl.MakeFile(ht.URL, w, ht.Context); err != nil {
h.RuntimeLog(err)
}
Expand All @@ -264,6 +251,9 @@ func (h *HTTPServer) run() error {
return bs
}})
}
mux.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {

})
for path, s := range h.arch {
mux.Handle(path, &archiveHandler{arch: s, createContext: h.Context, call: func(content *ctx.Result, err error, request *http.Request, writer http.ResponseWriter) {
for k, v := range h.header {
Expand Down

0 comments on commit 2700d83

Please sign in to comment.