You can edit almost every page by Creating an account and confirming your email.

HTTP multiplexer

From EverybodyWiki Bios & Wiki



HTTP Multiplexer or HTTP Request multiplexing is a technique by which an incoming HTTP request from a user agent is matched against registered patterns or routes, and the callback request handler is invoked for the best match.[1][note 1][2]

Functioning of the Multiplexer

The HTTP application router or multiplexer relies on a tree data structure, which makes use of Radix tree or prefix tree. For example:

Priority Path Request Handler
9 / Index
8 /s Index (no transition)
1 /search/ Search
1 /support/ Support
2 /blog/ BlogIndex
1 /blog/{\w+} BlogIndex (no transition)
1 /blog/{\w+}/ Blog
2 /contact-us/ GeneralContact
1 /contact-us/pr/ PRContact

Implementation

Every Request Handler is a callback function or a function pointer memory address that is registered to handle that HTTP endpoint. The placeholder or parameter for the endpoint is usually implemented using a state machine which accepts characters until it reaches a sentinel value i.e. '/' (forward-slash). The transition between each states updates the request handler callback that will be invoked. Since a pattern ending in a slash names a rooted subtree, the pattern "/" matches all paths not matched by other registered patterns, not just the URL with Path == "/".

Common features

Few of the common features of a HTTP multiplexer include:

  1. Request routing based on URL host, request path, path prefix, schemes, header, query values, HTTP method declaration and wildcard routes.
  2. Registered routes can be used as subroutes i.e. nested routing is only tested if the parent route matches. This is useful when defining a group of routes that share common conditions like HTTP Host header and prefix path.
  3. URL hosts, request paths, and query values can have placeholders for dynamic request processing, with optional regular expressions.

External Links

Notes

  1. HTTP Multiplexer should not be confused with HTTP/2 RFC 7540 5.1.2 multiplexing

References

  1. Szucs, Sandos (2018). "Modern HTTP Routing" (PDF). USENIX.
  2. Yellavula, Naren (2017). Building RESTful Web services with Go: Learn how to build powerful RESTful APIs with Golang that scale gracefully. Paket Publishing. ISBN 9781788291088. Search this book on



This article "HTTP multiplexer" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:HTTP multiplexer. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.