viniciussanchez/RESTRequest4Delphi
소개
어떤 프로그래밍 언어로 작성된 REST 서비스든 이용할 수 있는 API입니다. Lazarus와 Delphi를 지원합니다.
프로그래밍 언어 및 런타임측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Original
RESTRequest4Delphi is a API to consume REST services written in any programming language.
Designed to facilitate development, in a simple and minimalist way.
Buy our official training by clicking here!
⚙️ Installation
- Manual installation: Add the following folders to your project, in Project > Options > Building > Delphi Compiler > Search path
../RESTRequest4Delphi/src
- Installation using the 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 components are used by default. The RESTRequest4Delphi has support to five engines to make requests: RESTClient, Synapse, ICS Overbyte, 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, RR4D_ICS 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 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 - Adapter to load a DataSet using the DataSet-Serialize library at the time of the request;
- csv-adapter-restrequest4delphi - Allows you to generate a text or CSV file with the content of a request;
⚡️ Quickstart
You need to use RESTRequest4D
uses RESTRequest4D;
- GET
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
begin
TRequest.New.BaseURL('http://localhost:8888/users')
.Adapters(TDataSetSerializeAdapter.New(FDMemTable))
.Accept('application/json')
.Get;
end;
- POST
begin
TRequest.New.BaseURL('http://localhost:8888/users')
.ContentType('application/json')
.AddBody('{"name":"Vinicius","lastName":"Sanchez","email":"[email protected]"}')
.Post;
end;
- PUT
begin
TRequest.New.BaseURL('http://localhost:8888/users/1')
.ContentType('application/json')
.AddBody('{"name":"Vinicius","lastName":"Scandelai Sanchez","email":"[email protected]"}')
.Put;
end;
- DELETE
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:
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). To install using Boss, open a terminal and type:
boss install
If you prefer, you can manually download the DataSet-Serialize and add it to Search Path.
To run the server you will need Node.js and NPM. With everything installed, open a terminal, install the dependencies and run the server:
npm install
node server.js
💻 Code Contributors
⚠️ License
RESTRequest4Delphi is free and open-source software licensed under the MIT License.
관련 프로젝트 살펴보기
불러오는 중…