48 lines
9.9 KiB
HTML
48 lines
9.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>PathHandler (handy_http_handlers.path_handler.PathHandler)</title>
|
|
<meta charset="utf-8" />
|
|
<meta content="width=device-width, initial-scale=1" name="viewport" />
|
|
<link href="style.css" rel="stylesheet" />
|
|
<script src="script.js" type="text/javascript"></script>
|
|
|
|
|
|
<link href="search-results.html" rel="prefetch" />
|
|
</head>
|
|
<body>
|
|
<div id="page-header">
|
|
<div id="logotype">
|
|
<span>Documentation</span>
|
|
<nav>
|
|
<a href="http://dlang.org/">Dlang.org</a>
|
|
</nav>
|
|
</div>
|
|
|
|
<form action="search-docs.html" id="search">
|
|
<input name="searchTerm" placeholder="Find a symbol name..." type="search" />
|
|
<input type="submit" value="Go" />
|
|
</form>
|
|
</div>
|
|
<div id="page-body">
|
|
<div id="page-content">
|
|
<h1>PathHandler</h1><div class="breadcrumbs"><a class="breadcrumb" href="handy_http_handlers.html">handy_http_handlers</a> <a class="breadcrumb" href="handy_http_handlers.path_handler.html">path_handler</a> </div><div><div class="documentation-comment synopsis"><div><p>A request handler that maps incoming requests to a particular handler based
|
|
on the request's URL path and/or HTTP method (GET, POST, etc.).</p><p>Use the various overloaded versions of the <tt class="inline-code">addMapping(...)</tt> method to add
|
|
handlers to this path handler. When handling requests, this path handler
|
|
will look for matches deterministically in the order you add them. Therefore,
|
|
adding mappings with conflicting or duplicate paths will cause the first one
|
|
to always be called.</p><p>Path patterns should be defined according to the rules from the path-matcher
|
|
library, found here: <a href="https://github.com/andrewlalis/path-matcher">https://github.com/andrewlalis/path-matcher</a></p></div></div></div><div class="annotated-prototype"><div class="aggregate-prototype"><div class="attributes"></div><span class="builtin-type">class</span> PathHandler : HttpRequestHandler {<div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.this.html"><span class="lang-feature name">this</span>();</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.addMapping.1.html"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod method, string pattern, HttpRequestHandler handler);</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.addMapping.2.html"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod[] methods, string pattern, HttpRequestHandler handler);</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.addMapping.3.html"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod method, string[] patterns, HttpRequestHandler handler);</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.addMapping.4.html"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod[] methods, string[] patterns, HttpRequestHandler handler);</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.addMapping.5.html"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(string pattern, HttpRequestHandler handler);</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.setNotFoundHandler.html"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">setNotFoundHandler</span>(HttpRequestHandler handler);</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.handle.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">handle</span>(ServerHttpRequest request, ServerHttpResponse response);</a></div><div class="aggregate-member"><a href="handy_http_handlers.path_handler.PathHandler.registerHandlers.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">registerHandlers</span>();</a></div>}</div></div><h2 id="constructors"><a class="header-anchor" href="#constructors">Constructors</a></h2><dl class="member-list constructors"><dt><a href="handy_http_handlers.path_handler.PathHandler.this.html">this</a><div class="simplified-prototype" style="max-width: 6ch;"><span class="lang-feature name">this</span>()</div></dt><dd><div><p>Constructs a new path handler with initially no mappings, and a default
|
|
notFoundHandler that simply sets a 404 status.</p></div></dd></dl><h2 id="members"><a class="header-anchor" href="#members">Members</a></h2><h3 class="member-list-header hide-from-toc" id="function"><a class="header-anchor" href="#function">Functions</a></h3><dl class="member-list native"><dt><a href="handy_http_handlers.path_handler.PathHandler.addMapping.1.html">addMapping</a><div class="simplified-prototype" style="max-width: 93ch;"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod method, string pattern, HttpRequestHandler handler)</div></dt><dd><div><p>Adds a mapping to this handler, such that requests which match the given
|
|
method and pattern will be handed off to the given handler.</p></div></dd><dt><a href="handy_http_handlers.path_handler.PathHandler.addMapping.2.html">addMapping</a><div class="simplified-prototype" style="max-width: 96ch;"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod[] methods, string pattern, HttpRequestHandler handler)</div></dt><dd><div></div></dd><dt><a href="handy_http_handlers.path_handler.PathHandler.addMapping.3.html">addMapping</a><div class="simplified-prototype" style="max-width: 96ch;"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod method, string[] patterns, HttpRequestHandler handler)</div></dt><dd><div></div></dd><dt><a href="handy_http_handlers.path_handler.PathHandler.addMapping.4.html">addMapping</a><div class="simplified-prototype" style="max-width: 100ch;"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(HttpMethod[] methods, string[] patterns, HttpRequestHandler handler)</div></dt><dd><div></div></dd><dt><a href="handy_http_handlers.path_handler.PathHandler.addMapping.5.html">addMapping</a><div class="simplified-prototype" style="max-width: 72ch;"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">addMapping</span>(string pattern, HttpRequestHandler handler)</div></dt><dd><div></div></dd><dt><a href="handy_http_handlers.path_handler.PathHandler.handle.html">handle</a><div class="simplified-prototype" style="max-width: 73ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">handle</span>(ServerHttpRequest request, ServerHttpResponse response)</div></dt><dd><div><p>Handles a request by looking for a mapped handler whose method and pattern
|
|
match the request's, and letting that handler handle the request. If no
|
|
match is found, the notFoundHandler will take care of it.</p></div></dd><dt><a href="handy_http_handlers.path_handler.PathHandler.registerHandlers.html">registerHandlers</a><div class="simplified-prototype" style="max-width: 25ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">registerHandlers</span>()</div></dt><dd><div><p>Adds mappings to this path handler which correspond to functions defined
|
|
in the given symbol which have been annotated with the <tt class="inline-code">@PathMapping</tt>
|
|
attribute (or any simplified aliases like <tt class="inline-code">@GetMapping</tt>).</p></div></dd><dt><a href="handy_http_handlers.path_handler.PathHandler.setNotFoundHandler.html">setNotFoundHandler</a><div class="simplified-prototype" style="max-width: 63ch;"><tt class="highlighted"><span class="hid">PathHandler</span></tt> <span class="name">setNotFoundHandler</span>(HttpRequestHandler handler)</div></dt><dd><div><p>Sets the handler that will be called for requests that don't match any
|
|
pre-configured mappings.</p></div></dd></dl><div></div></div>
|
|
<div id="page-nav"><a class="parent" href="handy_http_handlers.html">handy_http_handlers</a> <a class="parent" href="handy_http_handlers.path_handler.html">path_handler</a>
|
|
<span class="type-separator">classes</span><ul><li><a class="class current" href="handy_http_handlers.path_handler.PathHandler.html">PathHandler</a></li><li><a class="class" href="handy_http_handlers.path_handler.PathHandlerContextData.html">PathHandlerContextData</a></li></ul><span class="type-separator">functions</span><ul><li><a class="function" href="handy_http_handlers.path_handler.getMethodBit.html">getMethodBit</a></li><li><a class="function" href="handy_http_handlers.path_handler.getPathParamAs.html">getPathParamAs</a></li><li><a class="function" href="handy_http_handlers.path_handler.getPathParams.html">getPathParams</a></li><li><a class="function" href="handy_http_handlers.path_handler.methodMaskFromAll.html">methodMaskFromAll</a></li><li><a class="function" href="handy_http_handlers.path_handler.methodMaskFromMethods.html">methodMaskFromMethods</a></li></ul><span class="type-separator">structs</span><ul><li><a class="struct" href="handy_http_handlers.path_handler.DeleteMapping.html">DeleteMapping</a></li><li><a class="struct" href="handy_http_handlers.path_handler.GetMapping.html">GetMapping</a></li><li><a class="struct" href="handy_http_handlers.path_handler.PatchMapping.html">PatchMapping</a></li><li><a class="struct" href="handy_http_handlers.path_handler.PathMapping.html">PathMapping</a></li><li><a class="struct" href="handy_http_handlers.path_handler.PostMapping.html">PostMapping</a></li><li><a class="struct" href="handy_http_handlers.path_handler.PutMapping.html">PutMapping</a></li></ul></div>
|
|
</div>
|
|
<div id="page-footer">Page generated by <a href="https://github.com/adamdruppe/adrdox">adrdox</a></div>
|
|
</body>
|
|
</html> |