Support setting of createdId via annotations
Comments (8)
-
-
Account Deactivated At the moment it has two cases:
- You do a PUT when creating a new instance of your resource, in which case it takes the request URL as the location
- You do a POST and the object you return has a field called
id, in which case it doesrequestUrl/$id
For the POST case I want to allow you to be able to use a field called something other than
idso I was thinking an annotation for that. E.g. if you doPOST /fooand your handler returns a Foo class like
class Foo { String fooPK; // other fields }and
fooPKis the unique key for that resource (i.e. you want the location to be /foo/${myFoo.fooPK}) then you could do a handler like@ CreatedId(#fooPK) Foo createFoo(String name) { // create a Foo somehow with a unique fooPK (e.g. save it into the DB and have the db auto generate the value) return foo; }Is that the kind of thing you are looking for or do you want to set the location manually (or both)?
-
You've described my use case exactly. Being able to to specify the unique key by annotation would be perfect - no need to set the location manually.
-
Account Deactivated cool I'll add something fairly soon. Likely add something to the
ResponseHeadersannotation e.g.class ResponseHeaders { ... Symbol idField; } -
Beautiful. Let me know if I can be of service.
-
Account Deactivated PR's (with unit test coverage) are always welcome ;-)
-
reporter - changed status to resolved
in 0.4.2
-
reporter - edited description
- changed title to Support setting of createdId via annotations
- Log in to comment
I was this close to filing an issue to request setting the Location header by annotation. Then I found (in bindings.dart, line 283):
Safe to say that's what you have in mind?