GithubHelp home page GithubHelp logo

tuxbr / restrequest4delphi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from viniciussanchez/restrequest4delphi

0.0 0.0 0.0 560 KB

API to consume REST services written in any programming language

License: MIT License

Pascal 100.00%

restrequest4delphi's Introduction

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

Prerequisites: DataSet-Serialize - This is a DataSet serializer for Delphi

  • Manual installation: Add the following folders to your project, in Project > Options > Resource Compiler > Directories and Conditionals > Include file search path
../RESTRequest4Delphi/src/core
../RESTRequest4Delphi/src/interfaces
  • Installation using the Boss:
boss install github.com/viniciussanchez/RESTRequest4Delphi

⚡️ Quickstart

You need to use RESTRequest4D.Request

uses RESTRequest4D.Request;
  • GET
begin
  TRequest.New.BaseURL('http://localhost:8888/users')
    .Accept('application/json')
    .Get;
end;
  • GET AS DATASET
begin
  TRequest.New.BaseURL('http://localhost:8888/users')
    .Accept('application/json')
    .DataSetAdapter(FDMemTable)
    .Get;
end;
  • POST
begin
  TRequest.New.BaseURL('http://localhost:8888/users')
    .Accept('application/json')
    .AddBody('{"name":"Vinicius","lastName":"Sanchez","email":"[email protected]"}')
    .Post;
end;
  • PUT
begin
  TRequest.New.BaseURL('http://localhost:8888/users/1')
    .Accept('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 or Token method before making the first request:

begin
  Request.BasicAuthentication('username', 'password');
  Request.Token('bearer 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

⚠️ License

RESTRequest4Delphi is free and open-source software licensed under the MIT License.

restrequest4delphi's People

Contributors

viniciussanchez avatar mateusvicente100 avatar andreldias93 avatar dliocode avatar murilobeluco avatar alissonmarquessouza avatar valdeirsk8 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.