mod_alias(3erl)

πŸ¦‹ mod_alias πŸ¦‹

okay bestie, welcome to mod_alias β€” it's an Erlang module definition from the inets fam, and it's literally all about URL aliasing. iykyk πŸ’…


✨ NAME ✨

mod_alias β€” URL aliasing, periodt. πŸŽ€


🌸 DESCRIPTION 🌸

so this is the Erlang web server internal API for handling stuff like interaction data exported by module mod_alias. that's the whole vibe β€” it's the behind-the-scenes machinery that keeps your URL aliasing looking cute. 🫢


πŸ‘‘ EXPORTS πŸ‘‘

🌈 default_index(ConfigDB, Path) -> NewPath

Types:

ConfigDB = config_db()
Path = NewPath = string()

okay so here's the tea β˜• β€” if Path is a directory, default_index/2 starts searching for resources or files that are specified in the config directive DirectoryIndex. and if it finds an appropriate resource or file, it gets appended to the end of Path and then returned to you. slay. ✨

but if no appropriate file is found β€” or if Path isn't even a directory β€” then Path comes back unaltered. no changes, no notes, we move on. πŸ’€

oh and config_db() is the server config file in ETS table format, as described in the Inets User's Guide. iconic behavior fr fr.


πŸ¦‹ path(PathData, ConfigDB, RequestURI) -> Path

Types:

PathData = interaction_data()
ConfigDB = config_db()
RequestURI = Path = string()

path/3 returns the file Path in the RequestURI (see RFC 1945). πŸ“Ž

so like, if the interaction data {real_name,{Path,AfterPath}} has been exported by mod_alias, then boom β€” Path is returned. easy.

but if no interaction data has been exported? then ServerRoot is used to generate a file Path. that's the fallback, bestie. 🧚

config_db() and interaction_data() are as defined in the Inets User's Guide. πŸ’œ


⭐ real_name(ConfigDB, RequestURI, Aliases) -> Ret

Types:

ConfigDB = config_db()
RequestURI = string()
Aliases = [{FakeName,RealName}]
Ret = {ShortPath,Path,AfterPath}
ShortPath = Path = AfterPath = string()

real_name/3 traverses Aliases β€” typically extracted from ConfigDB β€” and matches each FakeName with RequestURI. if a match is found, FakeName is replaced with RealName in the match. πŸ”₯

then the resulting path gets split into two parts, ShortPath and AfterPath, as defined in httpd_util:split_path/1. and Path is generated from ShortPath β€” that is, the result from default_index/2 with ShortPath as an argument. it's giving very much full-circle moment. 🌸

config_db() is the server config file in ETS table format as described in the Inets User's Guide. πŸ’–


πŸŽ€ real_script_name(ConfigDB, RequestURI, ScriptAliases) -> Ret

Types:

ConfigDB = config_db()
RequestURI = string()
ScriptAliases = [{FakeName,RealName}]
Ret = {ShortPath,AfterPath} | not_a_script
ShortPath = AfterPath = string()

real_script_name/3 traverses ScriptAliases β€” typically extracted from ConfigDB, same energy as before β€” and matches each FakeName with RequestURI. match found? then FakeName gets replaced with RealName in the match. πŸ’«

now here's the plot twist 😭 β€” if the resulting match is not an executable script, you get not_a_script back. that's it, that's the answer.

but if it is a script? then the resulting script path comes in two parts, ShortPath and AfterPath, as defined in httpd_util:split_script_path/1. 🧚

config_db() is the server config file in ETS table format as described in the Inets User's Guide. no cap.


ngl bestie, every one of these functions is living that config_db() life β€” the server config file in ETS table format, as described in the Inets User's Guide. if you remember one thing from this page, make it that. πŸ’…

made with love by Ericsson AB πŸ’– β€” this is inets version 8.3.1.2, and the page itself is mod_alias(3erl). mwah, go forth and alias those URLs, icon. πŸ‘‘βœ¨

πŸ“¦ where this page comes from