@@ -41,17 +41,15 @@ <h2>1. Introduction</h2>
4141#include <crails/request_parsers/url_parser.hpp>
4242#include <crails/request_parsers/form_parser.hpp>
4343#include <crails/request_parsers/multipart_parser.hpp>
44+ #include "server.hpp"
4445
4546using namespace Crails;
4647
47- const std::string Server::temporary_path = "/tmp";
48-
49- void Server::initialize_request_pipe()
48+ void ApplicationServer::initialize_request_pipe()
5049{
5150 add_request_parser(new RequestUrlParser);
5251 add_request_parser(new RequestFormParser);
5352 add_request_parser(new RequestMultipartParser);
54-
5553 add_request_handler(new ActionRequestHandler);
5654 add_request_handler(new FileRequestHandler);
5755}
@@ -76,12 +74,11 @@ <h3>1.1 Adding support for queries in json format</h3>
7674
7775< pre > < code class ="language-cpp "> #include <crails/request_parsers/json_parser.hpp>
7876#include <crails/request_handlers/action.hpp>
77+ #include "server.hpp"
7978
8079using namespace Crails;
8180
82- const std::string Server::temporary_path = "/tmp";
83-
84- void Server::initialize_request_pipe()
81+ void ApplicationServer::initialize_request_pipe()
8582{
8683 add_request_parser(new RequestJsonParser);
8784 add_request_handler(new ActionRequestHandler);
@@ -127,7 +124,8 @@ <h2>2. Writing your own request handler</h2>
127124</ code > </ pre >
128125
129126< p >
130- Simple stuff, really: overload < code > operator()</ code > , receive a < code > Crails::Context</ code >
127+ Simple stuff, really: overload < code > operator()</ code > , receive a
128+ < a href ="https://crails-framework.github.io/api-reference/#/classes/::Crails::Context " target ="_blank "> Crails::Context</ a >
131129 and a callback object.
132130</ p >
133131< p >
@@ -424,24 +422,15 @@ <h3>3.3 Fill in the Params object</h3>
424422
425423 load_yaml_tree(node, context.params);
426424}
427- CPP ).to_s); _erbout.<< "
425+ </ code > </ pre >
428426
429- <p>
430- Now there's still an issue remaining: if the parsing fail, < code> YAML::Load< /code> will throw an
427+ < p >
428+ Now there's still an issue remaining: if the parsing fail, < code > YAML::Load< /code > will throw an
431429 exception, and our server will respond with an error 500. That would be inaccurate, as the error
432- lies in the query. Let's update our <code>body_received</code> method to handle parsing errors:
433- </p>
434-
435- ".freeze
436-
437-
438-
439-
440-
441-
430+ lies in the query. Let's update our < code > body_received</ code > method to handle parsing errors:
431+ </ p >
442432
443- ; _erbout.<<(( code_block <<CPP
444- void MyRequestParser::body_received(Crails::Context& context, const std::string& body) const
433+ < pre > < code class ="language-cpp "> void MyRequestParser::body_received(Crails::Context& context, const std::string& body) const
445434{
446435 try
447436 {
0 commit comments