You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-@Path - set path of url for request. Combined class @Path annotation value and current method @Path. Path params passed with ":". For example @Path('/someurl/:someParam')
126
132
-@Headers - set headers for request (if annotate class, then all class methods getting this headers. method Headers merge with class Headers)
127
133
-@Produces - setting expected response type. By default Reponse transformed by .json() method
128
-
-@NoResponse (alias for @Produces(null)) - if expected empty response body, you need to set that annotation
129
-
-@DefaultResponse (alias for @Produces(Response)) - response doesn`t transformed with .json() method. Returned pure Response object
130
-
3) Parameters
134
+
-@Observes - setting http observes.
135
+
3) Parameters
131
136
-@PathParam (or @Path) - pass current parameter by name to collected url. Example: someFunc(@PathParam('id') itemId: number) {}
132
137
-@Body - pass body object into request. Ex.: someMethod(@Body bodyObject: any){}
133
138
-@QueryParam - pass single query parameters into request. Ex.: someMethod(@QueryParam('a') a: any, @QueryParam('b') b: any) {}. someMethod(1, 2) -> ..requested_url..?a=1&b=2
134
-
-@QueryParams - pass object with few query params. Ex.: someMethod(@QueryParams queryObj: any){}. someMethod({x: 1, y: 2, z: 3}) -> ..requested_url..?x=1&y=2&z=3
139
+
-@QueryParams - pass object with few query params. Ex.: someMethod(@QueryParams queryObj: any){}. someMethod({x: 1, y: 2, z: 3}) -> ..requested_url..?x=1&y=2&z=3
140
+
-@ResponseObservable - specify in witch function params, the response observable will be added. Ex.: someMethod(@ResponseObservable res: Observable<any> = undefined){ /* transform request */ return res; }. need to initialise as undefined to pass compile error, and return a response.
141
+
142
+
143
+
#### Transform response with all rxjs function
144
+
145
+
By adding the parameters @ResponseObservable you can specify, where add the observable response,
146
+
147
+
```typescript
148
+
149
+
@GET
150
+
@Path('posts')
151
+
/**
152
+
* getPostForUserId(3, 2) : call the the url /posts?userId=2 and only take 3 results
2) Create a service to work with rest api. Inherit it from HttpRestService from 'ngx-http-annotations'. Put annotations on the class, methods and params.
@GET, @POST, @PUT, @DELETE, @OPTIONS, @HEAD, @PATCH - marks methods implementing the corresponding requests
119
+
2) Added settings
120
+
-@Path - set path of url for request. Combined class @Path annotation value and current method @Path. Path params passed with ":". For example @Path('/someurl/:someParam')
121
+
-@Headers - set headers for request (if annotate class, then all class methods getting this headers. method Headers merge with class Headers)
122
+
-@Produces - setting expected response type. By default Reponse transformed by .json() method
123
+
-@Observes - setting http observes.
124
+
3) Parameters
125
+
-@PathParam (or @Path) - pass current parameter by name to collected url. Example: someFunc(@PathParam('id') itemId: number) {}
126
+
-@Body - pass body object into request. Ex.: someMethod(@Body bodyObject: any){}
127
+
-@QueryParam - pass single query parameters into request. Ex.: someMethod(@QueryParam('a') a: any, @QueryParam('b') b: any) {}. someMethod(1, 2) -> ..requested_url..?a=1&b=2
128
+
-@QueryParams - pass object with few query params. Ex.: someMethod(@QueryParams queryObj: any){}. someMethod({x: 1, y: 2, z: 3}) -> ..requested_url..?x=1&y=2&z=3
129
+
130
+
131
+
### Credits
132
+
133
+
Originaly created by "Mixalloff"
134
+
forked from https://github.com/Mixalloff/ngx-http-rest
0 commit comments