ServiceStack Service Design -
i creating new service stack application , want know if possible service stack; used message design pattern , have lot of requests dtos (about 100 request dtos); of requests inherit base request , each request dto has corresponding response dto; want generate generic service contains 4 methods get, post, put , delete; each 1 of these methods take baserequest parameter , return baseresponse return value , every concrete dtorequest determine rout; applicable in service stack; if not there alternative?
public class organizationservice : servicestack.service { public baseresponse post(baserequest request) { throw new notimplementedexception(); } public baseresponse update(baserequest updaterequest) { throw new notimplementedexception(); } public baseresponse delete(baserequest deleterequest) { throw new notimplementedexception(); } public baseresponse get(baserequest deleterequest) { throw new notimplementedexception(); } public baseresponse any(baserequest retrieverequest) { throw new notimplementedexception(); } } [route("/entities")] public class retrieveentityrequest : baserequest, ireturn<retrieveentityresponse> { /// <summary> /// unique identifier entity. /// </summary> public guid metadataid { get; set; } /// <summary> /// gets or sets name of entity retrieved. /// </summary> public string name { get; set; } /// <summary> /// gets or sets filter control how data entity retrieved. /// </summary> public entityfilters entityfilters { get; set; } /// <summary> /// gets or sets whether retrieve metadata has not been published yet. /// </summary> public boolean retrievenotpublisheddata { get; set; } }
you should not try create base service looks inherited base objects. servicestack not designed inheritance in rest method signatures. should stick specific dtos specific requests.
it fine have base request/response objects , there couple different ways work them. these hooks services. can use request/response filters or service runner. in methods can cast object baserequest , necessary work.
Comments
Post a Comment