mod_alias(3)
β¨ mod_alias β the URL-aliasing bestie of the Erlang web server β¨
okay so this is mod_alias, straight out of the Erlang Module Definition section of the inets manual (section 3, iykyk). she does URL aliasing. that's her whole thing. π
πΈ NAME πΈ
mod_alias β URL aliasing. that's it, that's the name. iconic behavior honestly.
π¦ DESCRIPTION π¦
okay so bestie, listen. mod_alias is an Erlang web server internal API β internal, meaning she's doing backstage work, not out here performing for randos. she handles stuff like interaction data that's been exported by the module mod_alias. so basically: she's the one holding the receipts when the web server needs to know where a URL actually points. no cap. π₯
π FUNCTIONS π
default_index(ConfigDB, Path) -> NewPath
default_index(ConfigDB, Path) -> NewPath
when
ConfigDB :: ets:tid(),
Path :: string(),
NewPath :: string().
so if Path is a directory, default_index/2 starts searching for resources or files that are specified in the config directive DirectoryIndex. π
if she finds an appropriate resource or file? it gets appended to the end of Path and then that new thing gets returned. slay.
if no appropriate file is found, or if Path isn't a directory at all? Path comes back unaltered. untouched. no changes. she just hands it right back to you. π«Ά
and config_db() β that's the server config file in ETS table format, as described in the Inets User's Guide. go read it, bestie, it's giving required reading. π
path(Data, ConfigDB, RequestURI) -> Path
path(Data, ConfigDB, RequestURI) -> Path
when
Data :: [{real_name, {Path, AfterPath}}],
ConfigDB :: ets:tid(),
RequestURI :: string(),
AfterPath :: string(),
Path :: string().
path/3 returns the file Path in the RequestURI β and yes, that's per RFC 1945, not vibes. π
so here's the tea:
- if the interaction data
{real_name, {Path, AfterPath}}has been exported bymod_alias, thenPathis what you get back. periodt. - if no interaction data has been exported, then
ServerRootis used to generate a filePath. she builds it from scratch, main character energy. β¨
config_db() and interaction_data() are as defined in the Inets User's Guide. same guide, same lore. π
real_name(ConfigDB, RequestURI, Aliases) -> ReturnPath
real_name(ConfigDB, RequestURI, Aliases) -> ReturnPath
when
ConfigDB :: ets:tid(),
RequestURI :: string(),
Aliases :: [{FakeName, RealName}],
ReturnPath :: {ShortPath, Path, AfterPath},
FakeName ::
re:mp() |
iodata() |
unicode:charlist() |
string(),
RealName :: string(),
ShortPath :: string(),
Path :: string(),
AfterPath :: string().
real_name/3 traverses Aliases β which are typically extracted from ConfigDB β and matches each FakeName against RequestURI. π
found a match? FakeName gets replaced with RealName in the match. glow-up complete. π
then the resulting path gets split into two parts: ShortPath and AfterPath, exactly as defined in httpd_util:split_path/1. don't ask her to split it a different way, she's using that function, that's the law. π
and Path? that's generated from ShortPath β aka it's the result of default_index/2 with ShortPath as the argument. she's calling her own friend, recursion-adjacent queen. π
config_db() is the server config file in ETS table format as described in the Inets User's Guide. (yes, again. it's a whole thing.) π
real_script_name(ConfigDB, RequestURI, ScriptAliases) -> ReturnPath | not_a_script
real_script_name(ConfigDB, RequestURI, ScriptAliases) ->
ReturnPath | not_a_script
when
ConfigDB :: ets:tid(),
RequestURI :: string(),
ScriptAliases ::
list() | [{FakeName, RealName}],
ReturnPath :: {ShortPath, AfterPath},
FakeName ::
re:mp() |
iodata() |
unicode:charlist() |
string(),
RealName :: string(),
ShortPath :: string(),
AfterPath :: term().
real_script_name/3 also traverses ScriptAliases β typically extracted from ConfigDB β and matches each FakeName with RequestURI. πβ¨
match found? FakeName gets replaced with RealName in the match. same deal as before. π
but here's the plot twist π«’: if the resulting match is not an executable script, then not_a_script is returned. that's it, that's the whole return value. she's not doing extra work for a non-script, she has boundaries.
if it is a script though? then the resulting script path comes in two parts β ShortPath and AfterPath β as defined in httpd_util:split_script_path/1. note that's split_script_path/1, not split_path/1, don't mix them up bestie, they are different functions and she will notice. π
config_db() is the server config file in ETS table format as described in the Inets User's Guide. (you knew this was coming by now.) π
β οΈ quick vibe check:config_db()andinteraction_data()both live in the Inets User's Guide, andconfig_db()is always the server config file in ETS table format. if you need those, that's where they are. no shortcuts, no guessing. π
and that's the whole page, bestie!! you ate this. π β¨
so this absolute banger of a manual page was brought to you by Ericsson AB, running on inets 9.7.2, filed under mod_alias(3). mwah. πππ¦πΈππβ
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms