From 3180ae97ef4b242a999cd8bd4a24fe923481bd8a Mon Sep 17 00:00:00 2001 From: Vinicius Sanchez Date: Mon, 4 Oct 2021 09:03:41 -0300 Subject: [PATCH] Samples Lazarus #5 --- boss-lock.json | 8 ++-- boss.json | 2 +- horse_basic_auth.dproj | 2 +- samples/boss-lock.json | 14 ------- samples/boss.json | 11 ----- samples/{ => delphi}/Samples.dpr | 0 samples/{ => delphi}/Samples.dproj | 3 +- samples/lazarus/Console.lpi | 64 ++++++++++++++++++++++++++++++ samples/lazarus/Console.lpr | 34 ++++++++++++++++ 9 files changed, 106 insertions(+), 32 deletions(-) delete mode 100644 samples/boss-lock.json delete mode 100644 samples/boss.json rename samples/{ => delphi}/Samples.dpr (100%) rename samples/{ => delphi}/Samples.dproj (99%) create mode 100644 samples/lazarus/Console.lpi create mode 100644 samples/lazarus/Console.lpr diff --git a/boss-lock.json b/boss-lock.json index 01075b9..0985131 100644 --- a/boss-lock.json +++ b/boss-lock.json @@ -1,11 +1,11 @@ { - "hash": "d41d8cd98f00b204e9800998ecf8427e", - "updated": "2019-07-15T22:22:24.4542686-03:00", + "hash": "8a53e9cf872feaac975a8fad2c6a5af0", + "updated": "2021-10-04T08:54:27.0678585-03:00", "installedModules": { "github.com/hashload/horse": { "name": "horse", - "version": "1.7.8", - "hash": "7f82adf0188b2f66e80e7a3c603558c9", + "version": "v2.0.14", + "hash": "38c6bebdc7b9712d6e5856d299289a26", "artifacts": {}, "failed": false, "changed": false diff --git a/boss.json b/boss.json index 836d828..6b42a11 100644 --- a/boss.json +++ b/boss.json @@ -6,6 +6,6 @@ "mainsrc": "/src", "projects": [], "dependencies": { - "github.com/hashload/horse": "^v2.0.0" + "github.com/hashload/horse": "^v2.0.14" } } \ No newline at end of file diff --git a/horse_basic_auth.dproj b/horse_basic_auth.dproj index 3a001c7..7f9dcc7 100644 --- a/horse_basic_auth.dproj +++ b/horse_basic_auth.dproj @@ -72,7 +72,7 @@ System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) All horse_basic_auth - modules\.dcp;modules\.dcu;modules;modules\horse\src;$(DCC_UnitSearchPath) + $(DCC_UnitSearchPath);modules\.dcp;modules\.dcu;modules;modules\horse\src true diff --git a/samples/boss-lock.json b/samples/boss-lock.json deleted file mode 100644 index 869dadd..0000000 --- a/samples/boss-lock.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "hash": "d41d8cd98f00b204e9800998ecf8427e", - "updated": "2020-09-04T08:15:07.8334739-03:00", - "installedModules": { - "github.com/hashload/horse": { - "name": "horse", - "version": "v2.0.0", - "hash": "e37b9706c16357ab94219cf12b67b036", - "artifacts": {}, - "failed": false, - "changed": false - } - } -} \ No newline at end of file diff --git a/samples/boss.json b/samples/boss.json deleted file mode 100644 index c8fd246..0000000 --- a/samples/boss.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "samples", - "description": "", - "version": "1.0.0", - "homepage": "", - "mainsrc": "./", - "projects": [], - "dependencies": { - "github.com/hashload/horse": "^v2.0.0" - } -} \ No newline at end of file diff --git a/samples/Samples.dpr b/samples/delphi/Samples.dpr similarity index 100% rename from samples/Samples.dpr rename to samples/delphi/Samples.dpr diff --git a/samples/Samples.dproj b/samples/delphi/Samples.dproj similarity index 99% rename from samples/Samples.dproj rename to samples/delphi/Samples.dproj index d7ea9e2..990b98a 100644 --- a/samples/Samples.dproj +++ b/samples/delphi/Samples.dproj @@ -49,7 +49,8 @@ false System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) Samples - modules\.dcp;modules\.dcu;$(DCC_UnitSearchPath);modules;modules\horse\src + ..\..\src;..\..\modules\horse\src;$(DCC_UnitSearchPath) + DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;tethering;svnui;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;svn;FireDACSqliteDriver;FireDACPgDriver;inetdb;soaprtl;DbxCommonDriver;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage) Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) diff --git a/samples/lazarus/Console.lpi b/samples/lazarus/Console.lpi new file mode 100644 index 0000000..e39db5c --- /dev/null +++ b/samples/lazarus/Console.lpi @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + <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> + <Units Count="1"> + <Unit0> + <Filename Value="Console.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="Console"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <OtherUnitFiles Value="..\..\src;..\..\modules\horse\src"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Other> + <CustomOptions Value="-dUseCThreads"/> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/samples/lazarus/Console.lpr b/samples/lazarus/Console.lpr new file mode 100644 index 0000000..f23edb5 --- /dev/null +++ b/samples/lazarus/Console.lpr @@ -0,0 +1,34 @@ +program Console; + +{$MODE DELPHI}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Horse, + Horse.BasicAuthentication, + SysUtils; + +procedure GetPing(Req: THorseRequest; Res: THorseResponse; Next: TNextProc); +begin + Res.Send('Pong'); +end; + +procedure OnListen(Horse: THorse); +begin + Writeln(Format('Server is runing on %s:%d', [Horse.Host, Horse.Port])); +end; + +function DoLogin(const AUsername, APassword: string): Boolean; +begin + Result := AUsername.Equals('user') and APassword.Equals('password'); +end; + +begin + THorse.Use(HorseBasicAuthentication(DoLogin)); + + THorse.Get('/ping', GetPing); + + THorse.Listen(9000, OnListen); +end.