| 275 | } |
| 276 | |
| 277 | static inline |
| 278 | bool EnsureAcceptHeader( |
| 279 | const HttpApiRequest& request, |
| 280 | HttpApiResponse& response, |
| 281 | boost::asio::yield_context& yc |
| 282 | ) |
| 283 | { |
| 284 | namespace http = boost::beast::http; |
| 285 | |
| 286 | if (request.method() != http::verb::get && request[http::field::accept] != "application/json") { |
| 287 | response.result(http::status::bad_request); |
| 288 | response.set(http::field::content_type, "text/html"); |
| 289 | response.body() << "<h1>Accept header is missing or not set to 'application/json'.</h1>"; |
| 290 | response.set(http::field::connection, "close"); |
| 291 | |
| 292 | response.Flush(yc); |
| 293 | |
| 294 | return false; |
| 295 | } |
| 296 | |
| 297 | return true; |
| 298 | } |
| 299 | |
| 300 | static inline |
| 301 | bool EnsureAuthenticatedUser( |