mod_alias(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

✨ 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 by mod_alias, then Path is what you get back. periodt.
  • if no interaction data has been exported, then ServerRoot is used to generate a file Path. 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() and interaction_data() both live in the Inets User's Guide, and config_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