Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by Mike_Lob

  1. Hi, First of all: Thank you for providing us with this wonderuful implentation of your Rest library Andrea. I'm converting my own API servers to work with your library since it's far more enhanced than mine. This being said .. 1. How can I enforce Attributes provided with GET or POST calls? I have read somewhere in your GIThub that it should be possible but I have yet to figure out how to do this. 2. How to dynamically change your database for a user. We have a Microsoft SQL server with a seperate database for every client. We also have one common database where we need to validate credentials and it will return the databasename from the sql server. For example: A user authenticates with an API key that we provied to the customer. That API key is linked to the users database and the SQL server returns that database name where we have to connect to - to perform specific user database queries. I have adjusted the authentication method to accept an API key: function TTokenResource.Authenticate(const AApiKey: string): Boolean; var tmpFound : boolean; begin DataModule1.FDQuery1.SQL.Text := 'select * from snippetexample'; Datamodule1.FDQuery1.Open(); Result := DataModule1.FDQuery1.RecordCount > 1; Result := false; //Result := true; end; Once authenticated we should open a database connection and start executing the users request and return a corresponding JSON. I have created a DATAmodule where my connection and query lives. I found that you can use a FIREDAC context : [Context] FD: TMARSFireDAC; But I cant figure out the right way to manipulate database connections for users, I could manually set users databases like so: FD.Connection.Params.DriverID := 'MSSQL'; FD.Connection.Params.Database := '...'; FD.Connection.Params.Server = 'ERROR'; But I feel this should not be done like this. Also the .Server param doesnt exist in this context. Please forgive me if you see any 'newbie' questions. I start learning Delphi 4 months ago and I have yet to discover all Delphi concepts... Thanks again for this awsome library!! If anything is unclear please let me know. Thanks for your time