Requests and Responses

By craig | March 16, 2020

In this post, we explore how to match incoming reuqests and define an appropriate response.

Matching inbound requests

Everytime an incoming request is received by ServeUp, it iterates through the list of routes to find one that matches the values in the incoming request.

The following attributes can be interrogated to determine whather the incoming request matches each route. The following section describes each of the matchable attributes.

The route also contains some informational notes that can be used to provide info about type of request that the route is trying to match.

And lastly, a route can be disabled which removes it from the list of routes that get evaluated.

HTTP Method

A route specifies the expected HTTP method. For example, GET, POST, PUT, et al.


A route can also match on a specific URL. Note that the values are compared against the fully specified URL (eg. http://localhost:8080/a/b/c/d?foo=bar#somefragment) including hostname, port number, query parameters, and fragments.

The possible matching options are:

  • Any - This will match any URL
  • Equals - Matches if the provided value exactly matches the fully specified inbound URL.
  • Not Equals - Matches if the provided value for not match the fully specified URL.
  • Contains - Matches if the provided value is contained within the fully specified URL. This is the most common scenario.
  • Regular Expression - Matches if the provided regular expression matches the fully specified URL.

Query String

A route can attempt to match on parameters contained in the query string. For example, the above screenshot is looking for a URL that contains a query parameter of foo that equals bar. For example, http://x.x.x.x/blah?foo=bar.

HTTP Header

A route can attempt to match on HTTP headers such as Authorization, or Accept-Encoding. In the example above, it is looking for an authorization token with a value of abcd.


A route can also match on the value of inbound cookies. Technically speaking, a cookie comes in as a HTTP header (so it could be matched there), however, ServeUp will parse the cookies and match on the individual cookie values.

Form Variables

Some requests contains encoded form variables in the HTTP body (eg. field1=somevalue&field2=123. ServeUp allows a route to specify that it must match on the value of a specific form variable.

JSON Variables

See the Variable substitution post for details on the supported syntax.