diff options
| author | Shulhan <ms@kilabit.info> | 2024-02-05 03:21:53 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-02-05 03:23:00 +0700 |
| commit | f2cfe0de0eeec8bc7abf9d754b9e89681743ecff (patch) | |
| tree | 802e8a32102a6786b4461e35b916d05b040558d0 /http_target.go | |
| parent | f02e4647bae78222196dc06406b5024c1b435bd7 (diff) | |
| download | gorankusu-f2cfe0de0eeec8bc7abf9d754b9e89681743ecff.tar.xz | |
all: implement form input file
The FormInput now can be set to FormInputKindFile that will rendered
as "<input type='file' ...>" on the web user interface.
Once submitted, the file name, type, size, and lastModification will
be stored under FormInput Filename, Filetype, Filesize, and Filemodms.
Implements: https://todo.sr.ht/~shulhan/trunks/1
Diffstat (limited to 'http_target.go')
| -rw-r--r-- | http_target.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/http_target.go b/http_target.go index be5919a..db55201 100644 --- a/http_target.go +++ b/http_target.go @@ -113,6 +113,15 @@ func (ht *HTTPTarget) init() (err error) { } if ht.Params == nil { ht.Params = KeyFormInput{} + } else { + var ( + key string + formInput FormInput + ) + for key, formInput = range ht.Params { + formInput.init() + ht.Params[key] = formInput + } } if len(ht.Path) == 0 { ht.Path = "/" @@ -206,6 +215,29 @@ func (ht *HTTPTarget) paramsToPath() { ht.Path = rute.String() } +// refCopy copy methods and handlers from orig to ht. +func (ht *HTTPTarget) refCopy(orig *HTTPTarget) { + ht.ConvertParams = orig.ConvertParams + ht.RequestDumper = orig.RequestDumper + ht.ResponseDumper = orig.ResponseDumper + + var ( + key string + fin FormInput + orgfin FormInput + ok bool + ) + for key, fin = range ht.Params { + if fin.Kind == FormInputKindFile { + orgfin, ok = orig.Params[key] + if ok { + fin.FormDataName = orgfin.FormDataName + ht.Params[key] = fin + } + } + } +} + func (ht *HTTPTarget) sortResults() { sort.Slice(ht.Results, func(x, y int) bool { return ht.Results[x].Name > ht.Results[y].Name |
