Commit Graph

50 Commits

Author SHA1 Message Date
Eugene Kabanov eee1f7ad04
Add one more version of `new(RestClientRef)` which accepts HttpAddress. (#57) 2023-09-04 16:10:21 +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
Jacek Sieka 8bb4a54f47
reduce imports (#56)
not needed, cause both http(s) server and client to be compiled
unnecessarily for any presto usage, including bearssl
2023-08-08 12:13:30 +02:00
Eugene Kabanov dceac3f5cc
Increase backlog defaults. (#54) 2023-08-01 13:28:25 +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 69b13d5047
Remove `connection` field from logging statements. (#49)
Keep `address` field first.
Fix warnings generated by macro usage.
Fix strutils warning.
2023-05-26 12:52:07 +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 ba20cebf0f
Add feature to enable HttpSessionRef idle timeout/period tuning. (#44) 2023-03-22 13:20:49 +02:00
tersec 18837545f3
disambiguous set 2023-02-24 14:45:00 +00: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 b1a02537b0
Fix shallowCopy nim-devel issue. (#39) 2022-09-28 06:04:08 +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
Jacek Sieka 3984431dc0
add missing imports (#36)
`options` no longer exported by chronos
2022-09-05 19:40:17 +02: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
Zahary Karadjov 1dba6dd6f4
Don't return 403 on "failing" CORS requests 2022-02-14 14:34:42 +02:00
Zahary Karadjov d82574ba24 Quick and dirty minimal implementation of CORS 2022-02-12 00:26:04 +02: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 de7f923c6b
More debug helpers (#18)
* Add connection_id to logs.
Add more logs.

* Fix chronicles issues.

* Fix SIGSEGV.

* Fix HTTP status logs.

* Bump chronos requirement to 3.0.9.
2021-12-03 18:14:25 +02:00
Eugene Kabanov c41bc8aefc
Add router.rawApi() macro and tests. (#17) 2021-11-29 17:14:10 +02:00
Etan Kissling 5a828c3ef1
fix `it` -> `is` typo (#16)
This fixes a minor typo in the log message `Request it not part of api`
and changes the `api` to uppercase for consistency with the other logs.
2021-11-27 03:22:25 +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 e96c6ded2a
Fix compilation warnings. (#13) 2021-08-13 03:14:46 +03:00
Eugene Kabanov 63fcc3df78
Fix request should be closed only at the end. (#10)
* Fix request should be closed only at the end.

* Final fix.
2021-06-10 20:35:08 +03:00
Eugene Kabanov 0c8c3a584d
Fix AsyncStreamIncompleteError exception leak. (#9)
* Fix AsyncStreamIncompleteError exception leak.

* Fix mistype.
2021-06-04 05:01:28 +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 37b25eaf2c
Move RestError declaration to common. (#7) 2021-05-15 02:39:22 +03:00
Eugene Kabanov db39cdcdc7
Fix chronicles compilation issue. (#6)
Export address variable.
2021-05-14 16:02:03 +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 ebb2c16c0d
Annotate callback with raises and perform fix for it. 2021-03-25 11:26:16 +02:00
cheatfate 2f01c838c6
Finally address comment about processRestRequest().
Fix compiler warning for testbtrees.
2021-03-25 10:35:58 +02:00
cheatfate 670f68acd1
Attempt to address comment with processRestRequest[T]() procedure. 2021-03-25 10:05:59 +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 ae185d2038
Fix presto to follow latest changes in chronos servers split. 2021-03-17 15:53: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 1b94fe21dd
Fix one more path problem. 2021-03-02 16:58:07 +02:00
cheatfate 9c9b061158
Initial implementation for review. 2021-03-02 15:50:16 +02:00