RESTRequest4Delphi

所属分类:collect
开发工具:Pascal
文件大小:0KB
下载次数:0
上传日期:2023-07-11 14:41:09
上 传 者sh-1993
说明:  使用任何编程语言编写的REST服务的API,支持Lazarus和Delphi
(API to consume REST services written in any programming language with support to Lazarus and Delphi)

文件列表:
LICENSE (1065, 2023-12-22)
boss-lock.json (121, 2023-12-22)
boss.json (148, 2023-12-22)
img/ (0, 2023-12-22)
img/logo.png (233695, 2023-12-22)
samples/ (0, 2023-12-22)
samples/client/ (0, 2023-12-22)
samples/client/delphi/ (0, 2023-12-22)
samples/client/delphi/Bin/ (0, 2023-12-22)
samples/client/delphi/Bin/RESTRequest4Delphi.pdf (131134, 2023-12-22)
samples/client/delphi/Samples.dpr (282, 2023-12-22)
samples/client/delphi/Samples.dproj (57164, 2023-12-22)
samples/client/delphi/src/ (0, 2023-12-22)
samples/client/delphi/src/Samples.Main.dfm (810125, 2023-12-22)
samples/client/delphi/src/Samples.Main.pas (5480, 2023-12-22)
samples/client/lazarus/ (0, 2023-12-22)
samples/client/lazarus/Samples.lpi (2101, 2023-12-22)
samples/client/lazarus/Samples.lpr (397, 2023-12-22)
samples/client/lazarus/src/ (0, 2023-12-22)
samples/client/lazarus/src/samples.main.lfm (371568, 2023-12-22)
samples/client/lazarus/src/samples.main.pas (2247, 2023-12-22)
samples/mercado-libre/ (0, 2023-12-22)
samples/mercado-libre/delphi/ (0, 2023-12-22)
samples/mercado-libre/delphi/mercadolibre.dpr (381, 2023-12-22)
samples/mercado-libre/delphi/mercadolibre.dproj (52939, 2023-12-22)
samples/mercado-libre/delphi/src/ (0, 2023-12-22)
samples/mercado-libre/delphi/src/Mercado.Libre.Consts.pas (5525, 2023-12-22)
samples/mercado-libre/delphi/src/Mercado.Libre.View.dfm (982, 2023-12-22)
samples/mercado-libre/delphi/src/Mercado.Libre.View.pas (1311, 2023-12-22)
samples/server-horse/ (0, 2023-12-22)
samples/server-horse/delphi/ (0, 2023-12-22)
samples/server-horse/delphi/Main.dfm (3825, 2023-12-22)
samples/server-horse/delphi/Main.pas (3775, 2023-12-22)
samples/server-horse/delphi/Server.dpr (262, 2023-12-22)
samples/server-horse/delphi/Server.dproj (63754, 2023-12-22)
samples/server-horse/lazarus/ (0, 2023-12-22)
... ...

Horse


RESTRequest4Delphi is a API to consume REST services written in any programming language.
Designed to facilitate development, in a simple and minimalist way.


## Installation * **Manual installation**: Add the following folders to your project, in *Project > Options > Resource Compiler > Directories and Conditionals > Include file search path* ``` ../RESTRequest4Delphi/src ``` * Installation using the [**Boss**](https://github.com/HashLoad/boss): ``` boss install github.com/viniciussanchez/RESTRequest4Delphi ``` ## Engines By default, the components **TRESTRequest**, **TRESTResponse** and **TRESTClient** are used to make requests when your using Delphi. If you use Lazarus, the [**fphttpclient**](https://wiki.lazarus.freepascal.org/fphttpclient) components are used by default. The RESTRequest4Delphi has support to four engines to make requests: RESTClient, [**Synapse**](http://www.ararat.cz/synapse/doku.php/download), Indy and NetHTTP. You can change the engine to make requests. To do this, simply define in: *Project > Options > Delphi Compiler > Conditional defines* the compiler directive `RR4D_INDY`, `RR4D_SYNAPSE` or `RR4D_NETHTTP` **Note**: for Lazarus, the **fphttpclient** engine is the default. But you can switch to **Indy** setting `RR4D_INDY` directive or to [**Synapse**](http://www.ararat.cz/synapse/doku.php/download) setting `RR4D_SYNAPSE` directive. ## Adapters Adapters allow you to extend the functionality of RESTREquest4Delphi without changing the core of the project. See the list of adapters available by the community: * [**dataset-serialize-adapter-restrequest4delphi**](https://github.com/viniciussanchez/dataset-serialize-adapter-restrequest4delphi) - Adapter to load a DataSet using the DataSet-Serialize library at the time of the request; ## Quickstart You need to use RESTRequest4D ```pascal uses RESTRequest4D; ``` * **GET** ```pascal var LResponse: IResponse; begin LResponse := TRequest.New.BaseURL('http://localhost:8888/users') .AddHeader('HeaderName', 'HeaderValue') .AddParam('ParameterName', 'ParameterValue') .Accept('application/json') .Get; if LResponse.StatusCode = 200 then ShowMessage(LResponse.Content); end; ``` * **GET AS DATASET USING ADAPTERS** ```pascal begin TRequest.New.BaseURL('http://localhost:8888/users') .Adapters(TDataSetSerializeAdapter.New(FDMemTable)) .Accept('application/json') .Get; end; ``` * **POST** ```pascal begin TRequest.New.BaseURL('http://localhost:8888/users') .ContentType('application/json') .AddBody('{"name":"Vinicius","lastName":"Sanchez","email":"viniciuss.sanchez@gmail.com"}') .Post; end; ``` * **PUT** ```pascal begin TRequest.New.BaseURL('http://localhost:8888/users/1') .ContentType('application/json') .AddBody('{"name":"Vinicius","lastName":"Scandelai Sanchez","email":"viniciuss.sanchez@gmail.com"}') .Put; end; ``` * **DELETE** ```pascal begin TRequest.New.BaseURL('http://localhost:8888/users/1') .Accept('application/json') .Delete; end; ``` ## Authentication You can set credentials using the `BasicAuthentication`, `Token` or `TokenBearer` method before making the first request: ```pascal begin Request.BasicAuthentication('username', 'password'); Request.Token('token-type ' + token); Request.TokenBearer(token); end; ``` You can set it once and it will be used for every request. ## Samples Two projects were developed within the examples folder: * **client**: Windows VCL application consuming a REST API developed in Node.js To run the project, you need to install its dependencies ([**DataSet-Serialize**](https://github.com/viniciussanchez/dataset-serialize)). To install using [**Boss**](https://github.com/HashLoad/boss), open a terminal and type: ``` boss install ``` If you prefer, you can manually download the `DataSet-Serialize` and add it to `Search Path`. * **server-node**: REST server developed with [**Node.js**](https://nodejs.org/en/) and [**Express**](https://expressjs.com/). To run the server you will need [**Node.js**](https://nodejs.org/en/) and [**NPM**](https://www.npmjs.com/). With everything installed, open a terminal, install the dependencies and run the server: ``` npm install node server.js ``` ## Code Contributors Code Contributors ## License `RESTRequest4Delphi` is free and open-source software licensed under the [MIT License](https://github.com/viniciussanchez/RESTRequest4Delphi/blob/master/LICENSE).

近期下载者

相关文件


收藏者