-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
600d6a5
commit 3180ae9
Showing
9 changed files
with
106 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CONFIG> | ||
<ProjectOptions> | ||
<Version Value="11"/> | ||
<PathDelim Value="\"/> | ||
<General> | ||
<Flags> | ||
<MainUnitHasCreateFormStatements Value="False"/> | ||
<MainUnitHasTitleStatement Value="False"/> | ||
<MainUnitHasScaledStatement Value="False"/> | ||
</Flags> | ||
<SessionStorage Value="InProjectDir"/> | ||
<MainUnit Value="0"/> | ||
<Title Value="Console"/> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |