Skip to content

Commit 7dfa310

Browse files
authored
'Resolving current request URL' section
1 parent 2aab689 commit 7dfa310

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

Examples/Apache/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ LuaPackagePath "{APP_FOLDER}/Handlers/?.lua"
3535
- {APP_FOLDER} = Apache www folder where your app/integration is located. Ex. 'C:/wamp64/www/lua'. Make sure SDK, Handlers and Helpers folders (incl. content) are copied here.
3636
- {URI_PATTERN} = Pattern used to match which URLs should go through the handler. https://httpd.apache.org/docs/trunk/mod/mod_lua.html#luamaphandler
3737

38+
#### Resolving current request URL
39+
The SDK needs to be able to resolve the current request URL. It does it by calling the function `getAbsoluteUri` located in *[ApacheHandlerUsingConfigFromFile](ApacheHandlerUsingConfigFromFile.lua)*.
40+
41+
Sometimes this function needs be be adjusted depending on what is available in your infrastructure. Could be that `r.is_https` and/or `r.hostname` are unavailable and then the function call would fail. In these cases you would need to replace with hardcoded values (or settings read from environment variables) ex.:
42+
43+
```
44+
iHelpers.request.getAbsoluteUri = function()
45+
local fullUrl = string.format("https://%s%s",
46+
"my-domain.example",
47+
r.unparsed_uri)
48+
r:debug(string.format("[%s] Rebuilt request URL as: %s", DEBUG_TAG, fullUrl))
49+
return fullUrl
50+
end
51+
```
52+
You will quickly notice if this function fails because its called on each request. Check you Apache logs for any warnings/errors.
53+
The example above (and default implementation) also contains `r:debug` so you can see what URLs are being built. It's important to note that these URLs should be public ones (e.g. use real domain, no internal IPs). You can test this by opening up a browser and visiting that generated URL.
54+
3855
## Alternative Implementation
3956

4057
### Queue configuration
@@ -80,4 +97,4 @@ function handle(request_rec)
8097
return apache2.DECLINED
8198
end
8299
end
83-
```
100+
```

0 commit comments

Comments
 (0)