Commit Graph

35 Commits

Author SHA1 Message Date
Eugene Kabanov e80546edf2
Add ability to handle REST server errors with custom responses. (#60)
* Add ability to handle REST server errors with custom responses.
Add tests.

* Fix chunked encoding issue.
Add test for chunked encoding.
2023-10-19 01:16:16 +03:00
Eugene Kabanov 2ae448ff5b
Add cancellation leaks tests. (#59) 2023-09-15 21:56:08 +03:00
Eugene Kabanov a30fcd4c29
Add client and server metrics. (#55)
* Add PRESTO client and server metrics which could be enabled per endpoint.

* Add dependency.

* Fix compilation issue.

* Address review comments.
2023-09-04 16:10:11 +03:00
Eugene Kabanov 42552611cf
Upgrade trackers (#53)
* Update presto to follow recent changes in chronos.

* Bump to reset CI testing.

* Bump requirements.

* Use chronos@head instead of specific version.

* Use proper delimiter to specify HEAD.
2023-07-17 09:44:27 +03:00
Eugene Kabanov 64365eb843
Expose HTTP response headers to RestPlainResponse. (#50) 2023-05-26 16:48:01 +03:00
Eugene Kabanov 9899be3c7f
Enable chronos.SocketFlags for REST client. (#48)
* Export SocketFlags for REST client.

* Apply fixes to REST client.
Upgrade ci workers 18.04 to 20.04 ubuntu.
2023-05-18 11:22:34 +03:00
Eugene Kabanov 2b440a443f
Allow empty POST requests (without body). (#45)
Add tests.
2023-03-30 21:04:33 +03:00
Eugene Kabanov 8bc34dd6f6
REST client connection management via connection pragma. (#41)
* Add REST client connection management pragma `connection` and tests.

* Fix merge issues.
2022-10-13 11:33:13 +00:00
Eugene Kabanov c784f3afb5
Allow REST client API functions to return HttpClientResponseRef. (#40)
* Initial implementation of HttpResponseRef support as result of calling REST API function.

* Fix missing return type.
Add tests.
2022-09-28 07:49:22 +00:00
Eugene Kabanov c17bfdda2c
Add REST status response (HTTP status code without any content). (#38)
Add new tests and fix old tests.
Fix content-type requirements for empty requests.
2022-09-27 15:18:06 +00:00
Eugene Kabanov 545849eebe
Support new chronos.Content-Type header parser. (#37) 2022-09-17 07:37:54 +03:00
zah d298b0ba30
text/text is not a standardized content type (#34)
https://www.w3.org/Protocols/rfc1341/7_1_Text.html
2022-08-10 01:06:26 +03:00
Eugene Kabanov b3dc03be6e
Use new Content-Type parser and adopt ContentBody structure for it. (#32) 2022-08-06 11:35:46 +03:00
tersec ec92aab102
--styleCheck:error (#31)
* --styleCheck:error

* --styleCheck:error iff >= Nim 1.6

* use supported macOS CI image
2022-07-26 13:57:02 +00:00
Eugene Kabanov 6e36cbc474
REST API response HTTP headers modification. (#28)
* Add support for HTTP response headers modification.

* Add tests for responses with headers.
2022-06-20 02:04:28 +03:00
Miran 4609bec638
move -d:nimRawSetjmp to nim.cfg (#27)
Refs https://github.com/status-im/nimbus-build-system/issues/44
2022-06-19 11:48:32 +03:00
cheatfate 668a2369f6 Enable usage of constants in `accept` pragma. 2022-02-08 11:16:22 +02:00
Emil 22746c5cd2 Fix `preferredContentType` calls
This change is needed due to refactoring of `preferredContentType` proc
in `nim-chronos`
2022-01-25 18:25:45 +02:00
Zahary Karadjov 80ebc5b419
Allow the 'api' macro to be used in generic functions 2022-01-06 20:20:20 +02:00
Zahary Karadjov fba35d5a67 Add support for passing extra headers in HTTP requests 2021-12-22 08:00:51 +02:00
Eugene Kabanov c41bc8aefc
Add router.rawApi() macro and tests. (#17) 2021-11-29 17:14:10 +02:00
Etan Kissling bfcbeceb65
allow reserved Nim keywords as REST params (#15)
This resolves a compilation error when specifying a reserved Nim keyword
as a REST parameter. The error was `node lacks field: strVal`, as the
corresponding identifiers need backticks embedding, e.g., `` `let` ``,
requiring an additional unwrap of `nnkAccQuoted` to get the raw ident.
2021-10-28 19:00:14 +03:00
Eugene Kabanov 9a7e711e22
Add Accept handling to REST server and client. (#12)
* Add Accept handling to REST server and client.
Add proper tests to server and client's test suites.
Fix some warnings.
Bump some nimble dependencies.

* Remove debugging echo.
2021-09-07 13:28:56 +03:00
Eugene Kabanov 5163805723
Add flag to pass comma delimited arrays by REST client. (#8)
Simplify server array decoding.
Add tests for comma delimited arrays.
2021-05-18 00:42:35 +03:00
Eugene Kabanov 80e28d15d6
Custom Response types introduced RestStatus, RestResponse[T], RestPlainResponse. (#5)
Added tests.
2021-05-11 18:31:43 +03:00
Eugene Kabanov d0ed144b9c
Rest client (#3)
* Separate some macro helper procedures to common module.
Initial commit for client.

* Arguments pre-processing and createPath() with tests.

* Further progress on arguments.

* Add method checks.

* REST client release candidate.

* Add redirection support to client requests.
Move all network logic to procedures.
Add first test.
Add PrestoIdent default to REST server and client.

* Add agent.

* Fix url encoding in request's path.

* Fix client url-encoding handling.
RestApiResponse become case-object.
Make `-d:nimDumpRest` the only one dumping procedure.
Add rest client tests.

* Add logging support.

* Bump chronos dependency version.
2021-05-10 11:28:58 +03:00
cheatfate 991b5836f6
Add `redirect` macro to allow path redirection.
Add tests for `redirect` macro.
Add check for unique patterns in path and tests.
2021-04-13 11:56:21 +03:00
cheatfate 2f01c838c6
Finally address comment about processRestRequest().
Fix compiler warning for testbtrees.
2021-03-25 10:35:58 +02:00
cheatfate 6687601ebb
Address review comments part 1. 2021-03-25 00:29:56 +02:00
cheatfate 32085aa97b
Add SecureRestServer implementation and tests. 2021-03-24 15:52:11 +02:00
cheatfate f2a51369d2
Change REST api error response to custom message with custom content-type. 2021-03-11 14:31:14 +02:00
cheatfate a61baae44c
Fix 32bit issues in tests. 2021-03-02 20:18:44 +02:00
cheatfate 1b94fe21dd
Fix one more path problem. 2021-03-02 16:58:07 +02:00
cheatfate d88d6471a8
Fix path problem. 2021-03-02 16:00:51 +02:00
cheatfate 9c9b061158
Initial implementation for review. 2021-03-02 15:50:16 +02:00