
RestRequest4delphi 는 모든 프로그래밍 언어로 작성된 REST 서비스를 소비하는 API입니다.
단순 하고 미니멀 한 방식으로 개발을 촉진하도록 설계되었습니다.
여기를 클릭 하여 공식 교육을 구입하십시오!
../RESTRequest4Delphi/src
boss install github.com/viniciussanchez/RESTRequest4Delphi
기본적으로 구성 요소 TrestRequest , Trestresponse 및 Trestclient는 Delphi를 사용할 때 요청을하는 데 사용됩니다. 나사로를 사용하는 경우 fphttpclient 구성 요소가 기본적으로 사용됩니다. lestrequest4delphi는 Restclient, Synapse , ICS Overbyte , Indy 및 Nethttp의 요청을하기 위해 5 개의 엔진을 지원합니다. 엔진을 변경하여 요청을 할 수 있습니다. 이렇게하려면 : project> 옵션> 델파이 컴파일러> 조건부 를 정의합니다. 조건부 RR4D_INDY , RR4D_SYNAPSE , RR4D_ICS 또는 RR4D_NETHTTP 정의합니다.
참고 : 나사로의 경우 fphttpclient 엔진이 기본값입니다. 그러나 Indy 설정 RR4D_INDY 지시문으로 전환하거나 RR4D_Synapse 지시문 RR4D_SYNAPSE 설정할 수 있습니다.
어댑터를 사용하면 프로젝트의 핵심을 변경하지 않고 restrequest4delphi의 기능을 확장 할 수 있습니다. 커뮤니티에서 사용할 수있는 어댑터 목록을 참조하십시오.
restrequest4d를 사용해야합니다
uses RESTRequest4D; 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 ; begin
TRequest.New.BaseURL( ' http://localhost:8888/users ' )
.Adapters(TDataSetSerializeAdapter.New(FDMemTable))
.Accept( ' application/json ' )
.Get;
end ; begin
TRequest.New.BaseURL( ' http://localhost:8888/users ' )
.ContentType( ' application/json ' )
.AddBody( ' {"name":"Vinicius","lastName":"Sanchez","email":"[email protected]"} ' )
.Post;
end ; begin
TRequest.New.BaseURL( ' http://localhost:8888/users/1 ' )
.ContentType( ' application/json ' )
.AddBody( ' {"name":"Vinicius","lastName":"Scandelai Sanchez","email":"[email protected]"} ' )
.Put;
end ; begin
TRequest.New.BaseURL( ' http://localhost:8888/users/1 ' )
.Accept( ' application/json ' )
.Delete;
end ; 첫 번째 요청을하기 전에 BasicAuthentication , Token 또는 TokenBearer 메소드를 사용하여 자격 증명을 설정할 수 있습니다.
begin
Request.BasicAuthentication( ' username ' , ' password ' );
Request.Token( ' token-type ' + token);
Request.TokenBearer(token);
end ;한 번 설정할 수 있으며 모든 요청에 사용됩니다.
예제 폴더 내에서 두 가지 프로젝트가 개발되었습니다.
프로젝트를 실행하려면 종속성을 설치해야합니다 ( DataSet-Serialize ). 보스를 사용하여 설치하려면 터미널을 엽니 다.
boss install
원하는 경우 DataSet-Serialize 수동으로 다운로드하여 Search Path 에 추가 할 수 있습니다.
서버를 실행하려면 node.js 및 npm이 필요합니다. 모든 것이 설치된 상태에서 터미널을 열고 종속성을 설치하고 서버를 실행하십시오.
npm install
node server.js
RESTRequest4Delphi MIT 라이센스에 따라 무료 및 오픈 소스 소프트웨어입니다.