Re: [Lazarus] SQLDBRestBridge

2022-11-03 Thread duilio foschi via lazarus
>Please look at the intercept example

could you please expand on this?

Where do I find the intercept example?

Thank you

Peppe

On Thu, Nov 3, 2022 at 11:17 PM Michael Van Canneyt via lazarus
 wrote:
>
>
>
> On Thu, 3 Nov 2022, duilio foschi wrote:
>
> > Hi Michael,
> >
> > I was able to log the info shown in this pic
> > https://i.ibb.co/f4MJQFJ/1.jpg
> >
> > (I used a rough writeln for now).
> >
> > This is fine when you want to verify the behaviour of the application 
> > itself.
> >
> > 1.
> > ==
> > Is there a way to have the server log HTTP commands received from the 
> > client?
> >
> > Like:
> > http://localhost:3000/EXPENSES?fmt=buf&humanreadable=1
>
> Yes.
>
> Please look at the intercept example. You can register an interceptor (a kind
> of middleware) and log all URLs.
>
>
> > 2.
> > ==
> > Is there a way to have the server log the data returned to the client?
> >
> > This data will be very valuable when trying to debug a client
> > developed by 3th parties that misbehave (what is my condition now).
> >
> > The alternative will be to use a HTTP proxy.
>
> Same here: you can register an interceptor for this, use the iaAfter to
> indicate that the interceptor takes place after the request was handled.
>
> The content should still be available in the response.content or
> response.contentstream.
>
> Michael.
> --
> ___
> lazarus mailing list
> lazarus@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] SQLDBRestBridge

2022-11-03 Thread Michael Van Canneyt via lazarus




On Thu, 3 Nov 2022, duilio foschi wrote:


Hi Michael,

I was able to log the info shown in this pic
https://i.ibb.co/f4MJQFJ/1.jpg

(I used a rough writeln for now).

This is fine when you want to verify the behaviour of the application itself.

1.
==
Is there a way to have the server log HTTP commands received from the client?

Like:
http://localhost:3000/EXPENSES?fmt=buf&humanreadable=1


Yes.

Please look at the intercept example. You can register an interceptor (a kind
of middleware) and log all URLs.



2.
==
Is there a way to have the server log the data returned to the client?

This data will be very valuable when trying to debug a client
developed by 3th parties that misbehave (what is my condition now).

The alternative will be to use a HTTP proxy.


Same here: you can register an interceptor for this, use the iaAfter to
indicate that the interceptor takes place after the request was handled.

The content should still be available in the response.content or
response.contentstream.

Michael.
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] SQLDBRestBridge

2022-11-03 Thread duilio foschi via lazarus
Hi Michael,

I was able to log the info shown in this pic
https://i.ibb.co/f4MJQFJ/1.jpg

(I used a rough writeln for now).

This is fine when you want to verify the behaviour of the application itself.

1.
==
Is there a way to have the server log HTTP commands received from the client?

Like:
http://localhost:3000/EXPENSES?fmt=buf&humanreadable=1

2.
==
Is there a way to have the server log the data returned to the client?

This data will be very valuable when trying to debug a client
developed by 3th parties that misbehave (what is my condition now).

The alternative will be to use a HTTP proxy.

Thank you

Peppe

On Thu, Nov 3, 2022 at 10:10 AM Michael Van Canneyt via lazarus
 wrote:
>
>
>
> On Thu, 3 Nov 2022, duilio foschi via lazarus wrote:
>
> > I could get client and server talk each other.
> >
> > For the future, it would be nice to have the server (when in debug
> > mode) write a log of commands and data exchanged with the client.
>
> This exists already. TRestDispatcherLogOption gives you this.
>
> In fact, there are 2 properties:
>
>  // Logging options
>  Property LogOptions : TRestDispatcherLogOptions Read FLogOptions write 
> FLogOptions default DefaultDispatcherLogOptions;
>  // SQL Log options. Only for connections managed by RestDispatcher
>  Property LogSQLOptions : TDBEventTypes Read FDBLogOptions write 
> FDBLogOptions default DefaultLogSQLOptions;
>
> And add a OnLog event handler.
>
> If you think some extra option is needed, let me know and I will see what I
> can do.
>
> Michael.
> --
> ___
> lazarus mailing list
> lazarus@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] SQLDBRestBridge

2022-11-03 Thread Michael Van Canneyt via lazarus




On Thu, 3 Nov 2022, duilio foschi via lazarus wrote:


I could get client and server talk each other.

For the future, it would be nice to have the server (when in debug
mode) write a log of commands and data exchanged with the client.


This exists already. TRestDispatcherLogOption gives you this.

In fact, there are 2 properties:

// Logging options
Property LogOptions : TRestDispatcherLogOptions Read FLogOptions write 
FLogOptions default DefaultDispatcherLogOptions;
// SQL Log options. Only for connections managed by RestDispatcher
Property LogSQLOptions : TDBEventTypes Read FDBLogOptions write 
FDBLogOptions default DefaultLogSQLOptions;

And add a OnLog event handler.

If you think some extra option is needed, let me know and I will see what I
can do.

Michael.
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] SQLDBRestBridge

2022-11-03 Thread duilio foschi via lazarus
I could get client and server talk each other.

For the future, it would be nice to have the server (when in debug
mode) write a log of commands and data exchanged with the client.

Both inbound and outbound commands/data are needed.

I have a hard time figuring out where to insert my code.

Any help?

Thank you

Peppe
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus