go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

multi form parameters in API

Open edieruby opened this issue 1 year ago • 6 comments

AReq { B []string form:"b,optional" }

It seems that this multi parameters does not support? Can support?

Similar like follow:

https://stackoverflow.com/questions/39736243/ho-to-bind-to-slice-values-in-go-gin-form https://github.com/gin-gonic/gin/issues/408

edieruby avatar Jul 06 '22 09:07 edieruby

It works well, there has a api which contains content as following

type Request {
	In []string `form:"in,optional"`
}

type Response {
	Out []string `json:"out"`
}

@server (
	group: test
)
service greet-api {
	@handler Greet
	post /list (Request) returns (Response)
}
go run greet.go
Starting server at 0.0.0.0:8888...
$ curl --request POST 'http://127.0.0.1:8888/list'
null%         

kesonan avatar Jul 11 '22 15:07 kesonan

type Request { A []string form:"a" }

type Response { Message string json:"message" }

service test-api { @handler TestHandler get /from (Request) returns (Response) }

curl --request GET 'http://127.0.0.1:8888/from?a=abc12&a=abc12'

response:

string: `abc12`, error: `invalid character 'a' looking for beginning of value`

edieruby avatar Jul 14 '22 02:07 edieruby

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Aug 14 '22 02:08 github-actions[bot]

Same question, so i has to set value by manual

wanghaoxi3000 avatar Sep 22 '22 06:09 wanghaoxi3000

I have the same question , but can not handle this issue

silves-xiang avatar Oct 29 '22 13:10 silves-xiang

Same question,in get request

cannian1 avatar Dec 11 '23 05:12 cannian1