Frontier: An abstraction layer for rapid REST development - Part 4 - Sharing data across router methods
Hello again and welcome to the next tutorial on this series: Part 4 - Sharing data across router methods. Here we are going to learn how to share a object containing data that is available for read across every router methods.
You're required to complete at least the Part 1 before entering this one. Still, this is supposed to be a really short tutorial, since there isn't much to be said about data sharing.
- Core concepts
- Getting started
- Creating a simple request
- Query parameters
- Aliasing query parameters
- Changing output format
- Rest query parameters
- Inferring object instances
- Using literal notation
- Seamlessly mixing instances with literals
- Returning streams
- Handling payloads
- How it works
- Making it useful
- Unmarshalling payloads into instances
- Using the unmarshaller to EDIT an existing object
- Using the SQL API
- Creating a simple dynamic query
- Overwriting the default container property
- Using cached queries
- Passing parameters to queries
- Sharing data across router methods
- Forcing API errors
- Managing errors with Reporters
4. Sharing data across router methods
Straight to the point, simply define a method called:
The data object is where you put whatever you need available for every method. This way all methods can access the data you provided by using:
This is the method that you would bind to some route. Like this one:
So now when you request a method using that Data, you'll notice that it can actually access it's contents.
This concludes the part 4. Next time, we're going to see how to force and handle application errors.
Keep in touch!