Open pnevyk opened 1 year ago
Hi, I took a look at the Rocket docs and it looks like a really cool idea but it would be quite a bit of work so I'm not sure I will be able to work on it at the moment.
Rocket also has support for nested structs which is very nice so I guess it would be easier to add support for everything at once. Let me look into it as soon as I have some free time and see if it's doable
Sure, take your time, it's not a blocker for me. Thanks!
The advanced features that Rocket supports are nice, but I wonder how much they are useful in practice.
Yeah that's a good point, I guess we could start with the names[]
and names[0]
convention for arrays, that would probably cover 99% of use cases
Nested structs too please. Sample use case, perhaps possible.
struct Student {
name: String,
avatar: FieldData<Bytes>
}
struct School {
name: String,
students: Vec<Student>,
avatar: FieldData<Bytes>
}
It seems that it's a common practice to use trailing square brackets (e.g.,
names[]=Foo
) when one wants to send multiple values with the same field name. For examples, here is the PHP manual for uploading multiple files and I found the same recommendations during internet search (1, 2).This would mean that for the following program:
the following request:
prints
names = ["Foo", "Bar"]
.Rocket and its FromForm derive trait supports this.
I think that supporting just
names[]
is a good start, later it would be nice to support things likenames[0]
(explicit ordering) or evennames[foo]
-> HashMap.If this is desired feature, I could try to send a PR. In that case and advice and pointers into the codebase would be appreciated.