How Functions Run
Understand how Ollie Hub intercepts requests, routes traffic, and executes your custom code seamlessly.
Ollie Hub acts as an intelligent proxy that intercepts requests to your target URLs and executes your custom functions. Learn how this interception works, how functions are routed and executed, and how to optimize performance.
Core Concept: Request Interception
How Ollie Hub Works
Request Interception
Ollie Hub receives requests intended for your target URL and captures all request details
Function Routing
Based on URL patterns and HTTP methods, Hub determines which function should handle the request
Code Execution
Your custom function executes with full access to request data and can modify the response
Response Enhancement
Optional Response Functions can further modify the output before returning to the user
URL Patterns and Routing
Ollie Hub uses a simple proxy pattern to intercept requests:
Ollie Hub uses a simple proxy pattern to intercept requests:
When multiple functions could handle the same request:
1. Exact Match
/api/users/profile
matches exactly
2. Parameter Match
/api/users/{id}
with dynamic segments
3. Wildcard Match
/api/users/*
catches all user routes
4. Catch-All
/*
handles everything else
Functions can be configured to handle specific HTTP methods:
Error Handling & Policies
Understanding how Ollie Hub handles function failures is crucial for building reliable applications. Each function can be configured with an error policy that determines what happens when execution fails.
Skip Policy
Behavior: Continue execution even if function fails
Use Case: Non-critical functions (analytics, logging, enhancements)
Impact: Request processing continues normally
Status: Function marked as skipped
Throw Policy
Behavior: Stop execution and return error if function fails
Use Case: Critical functions (authentication, validation, security)
Impact: Request fails with error response
Status: Function marked as failed
Error Policy Best Practices:
- Use
throw
for authentication, validation, and security functions - Use
skip
for analytics, logging, and enhancement functions - Consider the impact on user experience when choosing policies
When functions have different error policies, the Hub handles them intelligently:
Key Points:
- Request Functions: Execute sequentially, failures can stop the chain
- Response Functions: Execute in parallel, failures are handled independently
- Mixed Policies: Each function’s policy is evaluated individually
When functions have different error policies, the Hub handles them intelligently:
Key Points:
- Request Functions: Execute sequentially, failures can stop the chain
- Response Functions: Execute in parallel, failures are handled independently
- Mixed Policies: Each function’s policy is evaluated individually
All errors are logged with rich context for debugging:
Error Information Includes:
- Function ID and error policy
- Detailed error message and type
- Request context (URL, method, headers)
- Execution timestamp for debugging
The Hub tracks execution status for each function in response headers:
Use Cases:
- Debugging: See which functions ran and their outcomes
- Monitoring: Track function reliability and performance
- Analytics: Understand function usage patterns
- Troubleshooting: Quickly identify which functions are causing issues
Important: Functions with throw
policy will prevent subsequent functions from executing. Always consider the order and error policies when designing your function chain.
Next Steps
Request Functions
Learn to handle HTTP requests and build APIs
Response Functions
Enhance responses with custom logic
Task Functions
Automate workflows with scheduled tasks
Local Development
Test and debug functions locally
Best Practices
Follow proven patterns and optimizations
Key Insight: Ollie Hub acts as an intelligent proxy that intercepts your requests and executes custom code seamlessly. Understanding this flow helps you build more efficient and reliable functions.