zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
28.89k stars 3.91k forks source link

multi form parameters in API #2097

Open edieruby opened 2 years ago

edieruby commented 2 years ago

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

kesonan commented 2 years ago

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%         
edieruby commented 2 years ago

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`
github-actions[bot] commented 2 years ago

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

wanghaoxi3000 commented 1 year ago

Same question, so i has to set value by manual

silves-xiang commented 1 year ago

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

cannian1 commented 9 months ago

Same question,in get request

Of-qinhai commented 3 weeks ago

Up to now, the problem still exists, and there is no good solution