BlogAll Blog Posts | Next Post | Previous Post
Monday, June 24, 2019Well, actually I didn't forget it. I was just not blog about it.
But since we got a very positive feedback in the last post about new features in TMS XData 4.5, I decided to show you an extra thing, somewhat related to the parameter binding feature: it's the new EnableKeyAsSegment property.
Basically it controls how the endpoint URL for entities will look like. Let's take the SQLiteConsoleServer demo as an example. It automatically publishes all tables in the database without a single line of code, as Aurelius entities. If you run the demo and navigate to the swaggerui address you will see the available endpoints. In the screeshot below we can see the ones for Album entity:
Now let's see what happens when we set EnableKeyAsSegment property to True:
If you recompile, run the demo again and refresh the browser page to update SwaggerUI interface, here is what you get:
XDataServer1.EnableKeyAsSegment := True;
Did you notice the difference?
Yep, the URL format was
/Album(2)- the id enclosed in parenthesis - and now it is
/Album/2. Everything works just as before, and both URL are valid REST addresses, but having the ID in the path is a more common approach out there and might be easier for you to integrate with existing non-Delphi frameworks.
For entities with composite keys, you put one id in each path segment. For example, suppose you have an entity Order which is identified by CustomerId (string) and OrderNo (integer). Instead of using the URL
/Order(AFKLI,2)you can use
As one final note, when you enble the new URLs, the old ones are still valid. It's not a replacement, but an addition. The exception is in the SwwaggerUI itself, which hides the URLs using parenthesis to not clutter the UI too much.
Hope you liked this one, two!
Wagner R. Landgraf
This blog post has received 2 comments.
All Blog Posts | Next Post | Previous Post