/doc/core/z_dispatcher.html

https://code.google.com/p/zotonic/ · HTML · 140 lines · 118 code · 22 blank · 0 comment · 0 complexity · 5bc6e62b9b2e4e1ac36a37fe5b0b85fe MD5 · raw file

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Module z_dispatcher</title>
  5. <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
  6. </head>
  7. <body bgcolor="white">
  8. <div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  9. <hr>
  10. <h1>Module z_dispatcher</h1>
  11. <ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Manage dispatch lists (aka definitions for url patterns).
  12. <p>Copyright Š 2009 Marc Worrell
  13. </p>
  14. <p><b>Behaviours:</b> <a href="gen_server.html"><tt>gen_server</tt></a>.</p>
  15. <p><b>Authors:</b> Marc Worrell (<a href="mailto:marc@worrell.nl"><tt>marc@worrell.nl</tt></a>).</p>
  16. <h2><a name="description">Description</a></h2>Manage dispatch lists (aka definitions for url patterns). Constructs named urls from dispatch lists.
  17. <h2><a name="index">Function Index</a></h2>
  18. <table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#code_change-3">code_change/3</a></td><td>Convert process state when code is changed.</td></tr>
  19. <tr><td valign="top"><a href="#dispatchinfo-1">dispatchinfo/1</a></td><td>Fetch the dispatchlist for the site.</td></tr>
  20. <tr><td valign="top"><a href="#drop_port-1">drop_port/1</a></td><td>Drop the portnumber from the hostname.</td></tr>
  21. <tr><td valign="top"><a href="#handle_call-3">handle_call/3</a></td><td>Create the url for the dispatch rule with name and arguments Args.</td></tr>
  22. <tr><td valign="top"><a href="#handle_cast-2">handle_cast/2</a></td><td></td></tr>
  23. <tr><td valign="top"><a href="#handle_info-2">handle_info/2</a></td><td>Handling all non call/cast messages.</td></tr>
  24. <tr><td valign="top"><a href="#hostname-1">hostname/1</a></td><td>Fetch the preferred hostname for this site.</td></tr>
  25. <tr><td valign="top"><a href="#hostname_port-1">hostname_port/1</a></td><td>Fetch the preferred hostname, including port, for this site.</td></tr>
  26. <tr><td valign="top"><a href="#init-1">init/1</a></td><td>Initiates the server, loads the dispatch list into the webmachine dispatcher.</td></tr>
  27. <tr><td valign="top"><a href="#reload-1">reload/1</a></td><td>Reload all dispatch lists.</td></tr>
  28. <tr><td valign="top"><a href="#reload-2">reload/2</a></td><td></td></tr>
  29. <tr><td valign="top"><a href="#start_link-1">start_link/1</a></td><td>Starts the dispatch server.</td></tr>
  30. <tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td>This function is called by a gen_server when it is about to
  31. terminate.</td></tr>
  32. <tr><td valign="top"><a href="#update-1">update/1</a></td><td>Update the dispatch list but don't reload it yet.</td></tr>
  33. <tr><td valign="top"><a href="#url_for-2">url_for/2</a></td><td>Construct an uri from a named dispatch, assuming no parameters.</td></tr>
  34. <tr><td valign="top"><a href="#url_for-3">url_for/3</a></td><td>Construct an uri from a named dispatch and the parameters.</td></tr>
  35. <tr><td valign="top"><a href="#url_for-4">url_for/4</a></td><td>Construct an uri from a named dispatch and the parameters.</td></tr>
  36. </table>
  37. <h2><a name="functions">Function Details</a></h2>
  38. <h3 class="function"><a name="code_change-3">code_change/3</a></h3>
  39. <div class="spec">
  40. <p><tt>code_change(OldVsn, State, Extra) -&gt; {ok, NewState}</tt></p>
  41. </div><p>Convert process state when code is changed</p>
  42. <h3 class="function"><a name="dispatchinfo-1">dispatchinfo/1</a></h3>
  43. <div class="spec">
  44. <p><tt>dispatchinfo(Context) -&gt; {host, hostname, streamhost, smtphost, hostaliases, redirect, dispatchlist}</tt></p>
  45. </div><p>Fetch the dispatchlist for the site.</p>
  46. <h3 class="function"><a name="drop_port-1">drop_port/1</a></h3>
  47. <div class="spec">
  48. <p><tt>drop_port(Hostname) -&gt; any()</tt></p>
  49. </div><p>Drop the portnumber from the hostname
  50. </p>
  51. <h3 class="function"><a name="handle_call-3">handle_call/3</a></h3>
  52. <div class="spec">
  53. <p><tt>handle_call(X1::Request, From, State) -&gt; {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}</tt></p>
  54. </div><p>Create the url for the dispatch rule with name and arguments Args.</p>
  55. <h3 class="function"><a name="handle_cast-2">handle_cast/2</a></h3>
  56. <div class="spec">
  57. <p><tt>handle_cast(Msg, State) -&gt; {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}</tt></p>
  58. </div>
  59. <h3 class="function"><a name="handle_info-2">handle_info/2</a></h3>
  60. <div class="spec">
  61. <p><tt>handle_info(Info, State) -&gt; {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}</tt></p>
  62. </div><p>Handling all non call/cast messages</p>
  63. <h3 class="function"><a name="hostname-1">hostname/1</a></h3>
  64. <div class="spec">
  65. <p><tt>hostname(Context) -&gt; <a href="#type-iolist">iolist()</a></tt></p>
  66. </div><p>Fetch the preferred hostname for this site</p>
  67. <h3 class="function"><a name="hostname_port-1">hostname_port/1</a></h3>
  68. <div class="spec">
  69. <p><tt>hostname_port(Context) -&gt; <a href="#type-iolist">iolist()</a></tt></p>
  70. </div><p>Fetch the preferred hostname, including port, for this site</p>
  71. <h3 class="function"><a name="init-1">init/1</a></h3>
  72. <div class="spec">
  73. <p><tt>init(SiteProps::Args) -&gt; {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}</tt></p>
  74. </div><p>Initiates the server, loads the dispatch list into the webmachine dispatcher</p>
  75. <h3 class="function"><a name="reload-1">reload/1</a></h3>
  76. <div class="spec">
  77. <p><tt>reload(Context) -&gt; any()</tt></p>
  78. </div><p>Reload all dispatch lists. Finds new dispatch lists and adds them to the dispatcher</p>
  79. <h3 class="function"><a name="reload-2">reload/2</a></h3>
  80. <div class="spec">
  81. <p><tt>reload(X1, Context) -&gt; any()</tt></p>
  82. </div>
  83. <h3 class="function"><a name="start_link-1">start_link/1</a></h3>
  84. <div class="spec">
  85. <p><tt>start_link(SiteProps) -&gt; {ok, Pid} | ignore | {error, Error}</tt></p>
  86. </div><p>Starts the dispatch server</p>
  87. <h3 class="function"><a name="terminate-2">terminate/2</a></h3>
  88. <div class="spec">
  89. <p><tt>terminate(Reason, State) -&gt; <a href="#type-void">void()</a></tt></p>
  90. </div><p>This function is called by a gen_server when it is about to
  91. terminate. It should be the opposite of Module:init/1 and do any necessary
  92. cleaning up. When it returns, the gen_server terminates with Reason.
  93. The return value is ignored.</p>
  94. <h3 class="function"><a name="update-1">update/1</a></h3>
  95. <div class="spec">
  96. <p><tt>update(Context) -&gt; any()</tt></p>
  97. </div><p>Update the dispatch list but don't reload it yet. Used when flushing all sites, see z:flush/0</p>
  98. <h3 class="function"><a name="url_for-2">url_for/2</a></h3>
  99. <div class="spec">
  100. <p><tt>url_for(Name::atom(), Context) -&gt; <a href="#type-iolist">iolist()</a></tt></p>
  101. </div><p>Construct an uri from a named dispatch, assuming no parameters. Use html escape.</p>
  102. <h3 class="function"><a name="url_for-3">url_for/3</a></h3>
  103. <div class="spec">
  104. <p><tt>url_for(Name::atom(), Args, Context) -&gt; <a href="#type-iolist">iolist()</a></tt>
  105. <ul class="definitions"><li><tt>Args = <a href="#type-proplist">proplist()</a></tt></li>
  106. </ul></p>
  107. </div><p>Construct an uri from a named dispatch and the parameters. Use html escape.</p>
  108. <h3 class="function"><a name="url_for-4">url_for/4</a></h3>
  109. <div class="spec">
  110. <p><tt>url_for(Name::atom(), Args, Escape::atom(), Context) -&gt; <a href="#type-iolist">iolist()</a></tt>
  111. <ul class="definitions"><li><tt>Args = <a href="#type-proplist">proplist()</a></tt></li>
  112. </ul></p>
  113. </div><p>Construct an uri from a named dispatch and the parameters</p>
  114. <hr>
  115. <div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  116. <p><i>Generated by EDoc, Aug 12 2011, 20:01:39.</i></p>
  117. </body>
  118. </html>