* Demo of rest module

git-svn-id: trunk@60504 -
This commit is contained in:
michael 2019-02-25 20:29:42 +00:00
parent 9e70d0f58c
commit dc68f1bc5e
7 changed files with 374 additions and 0 deletions

6
.gitattributes vendored
View File

@ -1700,6 +1700,12 @@ components/fpweb/demo/restbridge/dmrestbridge.lfm svneol=native#text/plain
components/fpweb/demo/restbridge/dmrestbridge.pp svneol=native#text/plain
components/fpweb/demo/restbridge/restserver.lpi svneol=native#text/plain
components/fpweb/demo/restbridge/restserver.lpr svneol=native#text/plain
components/fpweb/demo/restmodule/demorestmodule.ico -text
components/fpweb/demo/restmodule/demorestmodule.lpi svneol=native#text/plain
components/fpweb/demo/restmodule/demorestmodule.lpr svneol=native#text/plain
components/fpweb/demo/restmodule/demorestmodule.res -text
components/fpweb/demo/restmodule/dmmyrest.lfm svneol=native#text/plain
components/fpweb/demo/restmodule/dmmyrest.pp svneol=native#text/plain
components/fpweb/fpideexteditorinsertfilenameunit.lfm svneol=native#text/plain
components/fpweb/fpideexteditorinsertfilenameunit.pas svneol=native#text/plain
components/fpweb/fpweb_images.inc svneol=native#text/plain

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="demorestmodule"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="lazsqldbrest"/>
</Item1>
<Item2>
<PackageName Value="WebLaz"/>
</Item2>
<Item3>
<PackageName Value="FCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="demorestmodule.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="dmmyrest.pp"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MyRest"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="DataModule"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,14 @@
program demorestmodule;
{$mode objfpc}{$H+}
uses
fphttpapp, dmmyrest, pqconnection;
begin
Application.Title:='httpproject1';
Application.Port:=8080;
Application.Initialize;
Application.Run;
end.

Binary file not shown.

View File

@ -0,0 +1,248 @@
object MyRest: TMyRest
OldCreateOrder = False
Dispatcher = MyDispatcher
Kind = wkOneShot
Height = 237
HorizontalOffset = 410
VerticalOffset = 280
Width = 595
PPI = 96
object MyDispatcher: TSQLDBRestDispatcher
Active = True
Connections = <
item
ConnectionType = 'PostgreSQL'
Name = 'Expenses'
Password = 'Secret'
UserName = 'Me'
CharSet = 'UTF8'
HostName = 'localhost'
DatabaseName = 'expensetracker'
Port = 0
end>
Schemas = <
item
Schema = ExpensesSchema
end>
Authenticator = AuthBasic
EnforceLimit = 0
left = 88
top = 56
end
object AuthBasic: TRestBasicAuthenticator
AuthenticateUserSQL.Strings = (
'select uID from users where (uLogin=:UserName) and (uPassword=:Password)'
)
left = 164
top = 132
end
object ExpensesSchema: TSQLDBRestSchema
Resources = <
item
Fields = <
item
FieldName = 'eid'
PublicName = 'eid'
GeneratorName = 'seqExpenseID'
FieldType = rftLargeInt
NativeFieldType = ftUnknown
Options = [foInKey, foInInsert, foInUpdate, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'euserfk'
PublicName = 'euserfk'
FieldType = rftLargeInt
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'eprojectfk'
PublicName = 'eprojectfk'
FieldType = rftLargeInt
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'etypefk'
PublicName = 'etypefk'
FieldType = rftLargeInt
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'eamount'
PublicName = 'eamount'
FieldType = rftFloat
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'edate'
PublicName = 'edate'
FieldType = rftDate
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'ecomment'
PublicName = 'ecomment'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 1024
end>
TableName = 'expenses'
ResourceName = 'expenses'
AllowedOperations = [roGet, roPost, roPut, roDelete, roOptions, roHead]
end
item
Fields = <
item
FieldName = 'etid'
PublicName = 'etid'
GeneratorName = 'seqExpenseTypesID'
FieldType = rftLargeInt
NativeFieldType = ftUnknown
Options = [foInKey, foInInsert, foInUpdate, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'etname'
PublicName = 'etname'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 50
end
item
FieldName = 'etdescription'
PublicName = 'etdescription'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 100
end
item
FieldName = 'etmaxamount'
PublicName = 'etmaxamount'
FieldType = rftFloat
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'etcost'
PublicName = 'etcost'
FieldType = rftFloat
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'etactive'
PublicName = 'etactive'
FieldType = rftBoolean
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end>
TableName = 'expensetypes'
ResourceName = 'expensetypes'
AllowedOperations = [roGet, roPost, roPut, roDelete, roOptions, roHead]
end
item
Fields = <
item
FieldName = 'pid'
PublicName = 'pid'
GeneratorName = 'seqProjectsID'
FieldType = rftLargeInt
NativeFieldType = ftUnknown
Options = [foInKey, foInInsert, foInUpdate, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'pname'
PublicName = 'pname'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 50
end
item
FieldName = 'pdescription'
PublicName = 'pdescription'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 100
end
item
FieldName = 'pactive'
PublicName = 'pactive'
FieldType = rftBoolean
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end>
TableName = 'projects'
ResourceName = 'projects'
AllowedOperations = [roGet, roPost, roPut, roDelete, roOptions, roHead]
end
item
Fields = <
item
FieldName = 'uid'
PublicName = 'uid'
GeneratorName = 'seqUsersID'
FieldType = rftLargeInt
NativeFieldType = ftUnknown
Options = [foInKey, foInInsert, foInUpdate, foOrderByDesc]
MaxLen = 0
end
item
FieldName = 'ulogin'
PublicName = 'ulogin'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 50
end
item
FieldName = 'ufullname'
PublicName = 'ufullname'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 100
end
item
FieldName = 'upassword'
PublicName = 'upassword'
FieldType = rftString
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 100
end
item
FieldName = 'uactive'
PublicName = 'uactive'
FieldType = rftBoolean
NativeFieldType = ftUnknown
Options = [foInInsert, foInUpdate, foFilter, foOrderByDesc]
MaxLen = 0
end>
TableName = 'users'
ResourceName = 'users'
AllowedOperations = [roGet, roPost, roPut, roDelete, roOptions, roHead]
end>
left = 268
top = 68
end
end

View File

@ -0,0 +1,35 @@
unit dmmyrest;
{$mode objfpc}{$H+}
interface
uses
SysUtils, Classes, HTTPDefs, fpHTTP, sqldbrestmodule, sqldbrestbridge,
sqldbrestauth, sqldbrestschema;
type
{ TMyRest }
TMyRest = class(TSQLDBRestModule)
AuthBasic: TRestBasicAuthenticator;
MyDispatcher: TSQLDBRestDispatcher;
ExpensesSchema: TSQLDBRestSchema;
private
public
end;
var
MyRest: TMyRest;
implementation
{$R *.lfm}
initialization
TMyRest.RegisterModule('REST');
end.