HTTP GET identifies a request method that middleware can use to select a response for an application route. section 17.2.2
A middleware check can:
- Inspect requestMethod to determine whether the request uses GET. section 17.2.2
- Inspect pathInfo to determine whether the request targets the root path (/). section 17.2.2
- Return HTML for a matching root request or delegate other requests to the wrapped application. section 17.2.2
Serving the todo page
A middleware function matches a GET request whose path is /, generates HTML for the todo entries, and otherwise passes control to the API server. section 17.2.2
import Network.HTTP.Types (methodGet)
...
mkAppRoot :: Connection -> Middleware
mkAppRoot dbConn app req responseAct
| isRootRequest = ...
| otherwise = app req responseAct
where
isRootRequest =
requestMethod req == methodGet
&& null (pathInfo req)
Inspect the complete root-request predicate, including the methodGet constant, requestMethod comparison, and empty path check. section 17.2.2













