From 6a9f897874c87b5d0127db478090fae6de9ad63f Mon Sep 17 00:00:00 2001 From: Matheus Hunsche Date: Tue, 2 Oct 2018 17:10:42 -0300 Subject: [PATCH] Initial Commit --- .gitignore | 38 +++ boss.json | 13 ++ jhonson.dpk | 37 +++ jhonson.dproj | 533 ++++++++++++++++++++++++++++++++++++++++++ src/Horse.Jhonson.pas | 40 ++++ 5 files changed, 661 insertions(+) create mode 100644 .gitignore create mode 100644 boss.json create mode 100644 jhonson.dpk create mode 100644 jhonson.dproj create mode 100644 src/Horse.Jhonson.pas diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de2f322 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +modules/ +dist/ +static/ +**/Win32/ +**/Win64/ +**/Linux64/ +**/__history/ +**/__recovery/ +src/*.~* +*.res +*.exe +*.dll +*.bpl +*.bpi +*.dcp +*.so +*.apk +*.drc +*.map +*.dres +*.rsm +*.tds +*.dcu +*.lib +*.a +*.o +*.ocx +*.local +*.identcache +*.projdata +*.tvsconfig +*.dsk +*.dcu +*.exe +*.so +*.~* +*.a +*.stat \ No newline at end of file diff --git a/boss.json b/boss.json new file mode 100644 index 0000000..1217110 --- /dev/null +++ b/boss.json @@ -0,0 +1,13 @@ +{ + "name": "jhonson", + "description": "", + "version": "1.0.0", + "private": false, + "homepage": "", + "mainsrc": "src/", + "supported": "xe+", + "dprojFile": "", + "dependencies": { + "github.com/HashLoad/horse": "^1.2.2" + } +} \ No newline at end of file diff --git a/jhonson.dpk b/jhonson.dpk new file mode 100644 index 0000000..b891fe4 --- /dev/null +++ b/jhonson.dpk @@ -0,0 +1,37 @@ +package jhonson; + +{$R *.res} +{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION OFF} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES ON} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DEFINE DEBUG} +{$ENDIF IMPLICITBUILDING} +{$RUNONLY} +{$IMPLICITBUILD ON} + +requires + rtl; + +contains + Jhonson in 'src\Jhonson.pas'; + +end. diff --git a/jhonson.dproj b/jhonson.dproj new file mode 100644 index 0000000..2703a50 --- /dev/null +++ b/jhonson.dproj @@ -0,0 +1,533 @@ + + + {EFEF97C4-6231-401E-BA6A-85C46DCF507D} + jhonson.dpk + 18.4 + None + True + Debug + Win32 + 1 + Package + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + .\$(Platform)\$(Config) + .\$(Platform)\$(Config) + false + false + false + false + false + true + true + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + All + true + jhonson + ;C:\Users\hunsc\projects\hashload\jhonson\modules\horse\src\;$(DCC_UnitSearchPath) + + + None + + + None + + + None + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + false + true + 1033 + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + + MainSource + + + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + Package + + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + jhonson.dpk + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + jhonson.bpl + true + + + + + 1 + + + Contents\MacOS + 0 + + + + + classes + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + + + res\values + 1 + + + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + + + 1 + + + 1 + + + 0 + + + + + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + + + + 1 + + + 1 + + + 1 + + + + + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 0 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + False + False + False + False + True + False + + + 12 + + + + + diff --git a/src/Horse.Jhonson.pas b/src/Horse.Jhonson.pas new file mode 100644 index 0000000..7e2afba --- /dev/null +++ b/src/Horse.Jhonson.pas @@ -0,0 +1,40 @@ +unit Horse.Jhonson; + +interface + +uses + Horse, System.Classes, System.JSON, Web.HTTPApp, System.SysUtils; + +procedure Jhonson(Req: THorseRequest; Res: THorseResponse; Next: TProc); + +implementation + +procedure Jhonson(Req: THorseRequest; Res: THorseResponse; Next: TProc); +var + LWebRequest: TWebRequest; + LWebResponse: TWebResponse; + LContent: TObject; + LJSON: TJSONValue; +begin + LWebRequest := THorseHackRequest(Req).GetWebRequest; + + if (LWebRequest.MethodType in [mtPost, mtPut]) and + (LWebRequest.ContentType = 'application/json') then + begin + LJSON := TJSONObject.ParseJSONValue(Req.Body); + THorseHackRequest(Req).SetBody(LJSON); + end; + + Next; + + LWebResponse := THorseHackResponse(Res).GetWebResponse; + LContent := THorseHackResponse(Res).GetContent; + + if LContent.InheritsFrom(TJSONValue) then + begin + LWebResponse.Content := TJSONValue(LContent).ToJSON; + LWebResponse.ContentType := 'application/json'; + end; +end; + +end.