aboutsummaryrefslogtreecommitdiffstats
path: root/include/Response.hpp
blob: 3e42d0d06f876a11047553528f75c70de5ef8770 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include "crow.h"

#include "AnnotationTypes.hpp"

namespace Response {
    using Reply::AnnotationType;
    typedef crow::json::wvalue json;

    // create a full response of just plain text
    json simple_response(std::string const &text, std::string const &session = "null", bool success = true);

    // create file attachment (is an annotation)
    json create_attachment(std::string const &file_path);
    json create_attachment(std::string const &file_path, std::string const &file_name);
    json create_attachment(std::string const &file_path, std::string const &file_name, std::string const &file_type);

    // "nested" annotations: the extra field is again an array of text-annotation pairs
    json create_annotation(AnnotationType annotation, std::vector<json> &&extra);
    // construct an extra field with no special annotations in the extra
    json create_annotation(AnnotationType annotation = AnnotationType::none, std::string const &extra = "");

    // text with no special annotation
    json create_text(std::string const &text);
    // text with annotations
    json create_text(std::string const &text, std::vector<json> &&annotations);

    // create a response from multiple texts
    json create_response(std::vector<json> &&reply, std::string const &session = "null", bool success = true);
}