Mercurial > hg > orthanc
comparison Core/RestApi/RestApiOutput.cpp @ 210:96b7918a6a18
start of the refactoring of the Orthanc REST API
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Nov 2012 18:03:44 +0100 |
parents | 9960642f0f45 |
children | b7aea293b965 |
comparison
equal
deleted
inserted
replaced
209:9960642f0f45 | 210:96b7918a6a18 |
---|---|
32 | 32 |
33 #include "RestApiOutput.h" | 33 #include "RestApiOutput.h" |
34 | 34 |
35 namespace Orthanc | 35 namespace Orthanc |
36 { | 36 { |
37 RestApiOutput::RestApiOutput(HttpOutput& output) : | |
38 output_(output) | |
39 { | |
40 existingResource_ = false; | |
41 } | |
42 | |
43 | |
44 RestApiOutput::~RestApiOutput() | |
45 { | |
46 if (!existingResource_) | |
47 { | |
48 output_.SendHeader(Orthanc_HttpStatus_400_BadRequest); | |
49 } | |
50 } | |
51 | |
37 void RestApiOutput::AnswerFile(HttpFileSender& sender) | 52 void RestApiOutput::AnswerFile(HttpFileSender& sender) |
38 { | 53 { |
39 sender.Send(output_); | 54 sender.Send(output_); |
55 existingResource_ = true; | |
40 } | 56 } |
41 | 57 |
42 void RestApiOutput::AnswerJson(const Json::Value& value) | 58 void RestApiOutput::AnswerJson(const Json::Value& value) |
43 { | 59 { |
44 Json::StyledWriter writer; | 60 Json::StyledWriter writer; |
45 std::string s = writer.write(value); | 61 std::string s = writer.write(value); |
46 output_.AnswerBufferWithContentType(s, "application/json"); | 62 output_.AnswerBufferWithContentType(s, "application/json"); |
63 existingResource_ = true; | |
47 } | 64 } |
48 | 65 |
49 void RestApiOutput::AnswerBuffer(const std::string& buffer, | 66 void RestApiOutput::AnswerBuffer(const std::string& buffer, |
50 const std::string& contentType) | 67 const std::string& contentType) |
51 { | 68 { |
52 output_.AnswerBufferWithContentType(buffer, contentType); | 69 output_.AnswerBufferWithContentType(buffer, contentType); |
70 existingResource_ = true; | |
53 } | 71 } |
54 | 72 |
55 void RestApiOutput::Redirect(const char* path) | 73 void RestApiOutput::Redirect(const char* path) |
56 { | 74 { |
57 output_.Redirect(path); | 75 output_.Redirect(path); |
76 existingResource_ = true; | |
58 } | 77 } |
59 } | 78 } |