Fastly Compute C++ SDK
Loading...
Searching...
No Matches
robots.txt.cpp
// Based on https://www.fastly.com/documentation/solutions/examples/serve-robots-txt-from-the-edge/
#include "fastly/sdk.h"
int main() {
if (req.get_method() == fastly::http::Method::GET &&
req.get_path() == "/robots.txt") {
fastly::Response::from_body("User-agent: BadBot\nDisallow: /\n")
} else {
fastly::Response::from_body("The page you requested could not be found")
}
}
int main()
Definition async_reqs.cpp:10
static Request from_client()
static Response from_body(Body body)
Create a new Response with the given value as the body.
Response with_status(StatusCode status) &&
Builder-style equivalent of Response::set_status().
static const StatusCode NOT_FOUND
Definition status_code.h:129