Skip to content

littleearth/lazy-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LazyREST

logo

LazyREST is a quick HTTP(s) web server that will accept JSON data for any simple endpoint. It stores data in flat JSON files to allow quick setup for mock and testing environments.

image

For example

Postman samples are included in the installation or source

Web pages can also be served by placing them into the HTML folder.

A default template modified from HTML5UP has been provided.

Icons are from Icons8

Post

Body should contain valid JSON. The server has a global Validate JSON option but you can also toggle on each call.

{
 "firstName": "Mary",
 "lastName": "Jane"
}

The REST endpoint will generate a GUID your data is stored into and respond with the ID or an ID can be forced with the id parameter

{
	"id": "123"
}

Put

Body should contain valid JSON eg

{
 "firstName": "Mary",
 "lastName": "Jane"
}

A PUT request will update and existing entry or create a new entry with the specified ID. The response will be the ID

{
	"id": "123"
}

Get

Get supports simple text searching as well as a limit and offset to allow simple pagination

[
 {
  "firstName": "Mary",
  "lastName": "Jane"
 },
 {
  "firstName": "Fred",
  "lastName": "Bloggs"
 }
]

Delete

Delete can delete a specific entry or all entries. The softdelete parameter will just rename the file from .json to .del to allow quick restoration of a record. The response will be the ID or list of ID's deleted.

[
{
"ID": "04F8E7F8-4BE4-42EE-971B-66E8EF44CE80"
},
{
"ID": "123"
},
{
"ID": "3F686925-672F-44A9-925C-BA7743DF0D8F"
},
{
"ID": "443A668F-DF83-4B2D-B3D4-B151E59F3E37"
}
]

Use Cases

Prototype

Prototype a Web or Firemonkey mobile application and make it actually work with simple REST endpoints but no need for schema or database

Data Gathering

Submitted PC details via powershell to quickly generate a report on makes and model

$url = "http://localhost:14544/pcdata"
$url = "$url/$id"
Write-Host "Status: Submitting PC details to $url"
try {
$result = Invoke-WebRequest -Uri $url -ContentType "application/json" -Method PUT -Body $json 
if ($result.StatusCode -eq 200) {
Write-Host "Success: Data has been submitted for PC id $id"
} else {
Write-Host $result.StatusDescription
}
} catch {
  Write-Host "Failed: Failed to submit data, error: $_"
}

Compiling

Delphi 10.4 is the current target version for compilation

Components

About

LazyREST is a quick HTTP(s) web server that will accept JSON data for any simple endpoint. It stores data in flat JSON files to allow quick setup for mock and testing environments.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors