mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 23:21:57 +02:00
* Fix failure to compile due to dynamic HTTP statuses. Make option to enforce XML output
git-svn-id: trunk@41658 -
This commit is contained in:
parent
e32d18977c
commit
d1a180b386
@ -57,7 +57,7 @@ function TXMLSQLDBRestDispatcher.CreateOutputStreamer(IO: TRestIO): TRestOutputS
|
||||
begin
|
||||
io.Response.ContentStream:=TMemoryStream.Create;
|
||||
io.Response.FreeContentStream:=True;
|
||||
Result:=TXMLOutputStreamer.Create(IO.Response.ContentStream,Strings,@IO.DoGetVariable);
|
||||
Result:=TXMLOutputStreamer.Create(IO.Response.ContentStream,Strings,Statuses, @IO.DoGetVariable);
|
||||
end;
|
||||
|
||||
{ TRestServerDemoApplication }
|
||||
@ -91,18 +91,22 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
Port:=3000;
|
||||
FDisp:=TSQLDBRestDispatcher.Create(Self);
|
||||
if HasOption('x','xml-only') then
|
||||
FDisp:=TXMLSQLDBRestDispatcher.Create(Self)
|
||||
else
|
||||
FDisp:=TSQLDBRestDispatcher.Create(Self);
|
||||
if HasOption('c', 'config') then
|
||||
FDisp.LoadFromFile(GetOptionValue('c', 'config'),[dioSkipReadSchemas])
|
||||
else
|
||||
begin
|
||||
// create a Default setup
|
||||
FAuth:=TRestBasicAuthenticator.Create(Self);
|
||||
// This is not the DB user !
|
||||
FAuth.DefaultUserName:='me';
|
||||
FAuth.DefaultPassword:='secret';
|
||||
FAuth.AuthenticateUserSQL.Text:='select uID from users where (uLogin=:UserName) and (uPassword=:Password)';
|
||||
FDisp.DispatchOptions:=FDisp.DispatchOptions+[rdoConnectionInURL,rdoCustomView,rdoHandleCORS];
|
||||
FDisp.ExposeDatabase(TPQConnectionDef.TypeName,'localhost','expensetracker','me','secret',Nil,[foFilter,foInInsert,foInUpdate,foOrderByDesc]);
|
||||
FDisp.DispatchOptions:=FDisp.DispatchOptions+[rdoCustomView,rdoHandleCORS];
|
||||
FDisp.ExposeDatabase(TPQConnectionDef.TypeName,'localhost','expensetracker','You','YourSecret',Nil,[foFilter,foInInsert,foInUpdate,foOrderByDesc]);
|
||||
With FDisp.Schemas[0].Schema.Resources do
|
||||
begin
|
||||
FindResourceByName('users').Fields.FindByFieldName('uID').GeneratorName:='seqUsersID';
|
||||
@ -146,6 +150,7 @@ begin
|
||||
Writeln('-c --config=File Read config from .ini file');
|
||||
Writeln('-m --max-requests=N Server at most N requests, then quit.');
|
||||
Writeln('-s --saveconfig=File Write config to .ini file (ignored when -c or --config is used)');
|
||||
Writeln('-x --xml-only Only allow XML requests)');
|
||||
end;
|
||||
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user