We are not going to go over general information on REST services there is plenty of information available. This multi part post is meant to show how to use our open source library to create REST services using DataFlex WebApp.

The library helps by hiding the complexity of handling the following

  • Routing / Paths
  • Authentication
  • Schemas/Data Models
  • Paging / Sorting
  • OpenAPI Documentation
  • Error Handling
  • and more

Routing / Paths

Routing is one of the important features of a REST service controller. Lets take a customer controller as an example.

We want the following features

  • get list of customers
  • get customer by number
  • get orders for customer
  • create customer
  • update customer
  • delete customer

The routes we would define are as follows

  • GET /customer
  • GET /customer/{number}
  • GET /customer/{number}/orders
  • POST /customer
  • PATCH /customer/{number}
  • DELETE /customer/{number}

it can be tedious to have to code these routes over and over so the library takes care of handling the routes and route parameters for you and even handles all the database work for you.

Authentication

Most REST services require some sort of authentication. Often multiple different authentications and also often different per route.

The library helps define and handle authentication by allowing the user to define default authentication for the controller and then override the authentication per route.

Schemas / Data Models

The library allows definition of schemas / data models. This is used to automate data output and input, ensure data integrity and is also used to document the service to a possible user using OpenAPI specifications

Paging / Sorting

 Paging and sorting capabilities are implemented in the library as well

OpenAPI documentation

The library can automatically document the API using OpenAPI specifications. This makes it easy to test the API using swagger and also helps documenting the API to a possible user.

After this quick overview we will look into creating a few different APIs to showcase the features of the library.

 

 

 

Michael Salzlechner is the CEO of StarZen Technologies, Inc.

He was part of the Windows Team at Data Access Worldwide that created the DataFlex for Windows Product before joining StarZen Technologies. StarZen Technologies provides consulting services as well as custom Application development and third party products