File: CustomCtrl.h

package info (click to toggle)
drogon 1.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,096 kB
  • sloc: cpp: 52,222; sh: 249; xml: 20; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (2)
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
#pragma once
#include <drogon/HttpController.h>
using namespace drogon;

class CustomCtrl : public drogon::HttpController<CustomCtrl, false>
{
  public:
    METHOD_LIST_BEGIN
    // use METHOD_ADD to add your custom processing function here;
    METHOD_ADD(CustomCtrl::hello,
               "/{userName}",
               Get,
               "CustomHeaderFilter");  // path is /customctrl/{arg1}
    METHOD_LIST_END

    explicit CustomCtrl(const std::string &greetings) : greetings_(greetings)
    {
    }

    void hello(const HttpRequestPtr &req,
               std::function<void(const HttpResponsePtr &)> &&callback,
               const std::string &userName) const;

  private:
    std::string greetings_;
};