File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ void Router::handle(ContextSptr sp_ctx, const NextFunc &next)
45
45
case Method::kPut : prefix = " put:" ; break ;
46
46
case Method::kPost : prefix = " post:" ; break ;
47
47
case Method::kDelete : prefix = " del:" ; break ;
48
+ case Method::kOptions : prefix = " opt:" ; break ;
49
+ case Method::kHead : prefix = " head:" ; break ;
50
+ case Method::kTrace : prefix = " trace:" ; break ;
48
51
default :;
49
52
}
50
53
@@ -82,6 +85,24 @@ Router& Router::del(const std::string &path, const RequestCallback &cb)
82
85
return *this ;
83
86
}
84
87
88
+ Router& Router::opt (const std::string &path, const RequestCallback &cb)
89
+ {
90
+ d_->cbs_ [std::string (" opt:" ) + path] = cb;
91
+ return *this ;
92
+ }
93
+
94
+ Router& Router::head (const std::string &path, const RequestCallback &cb)
95
+ {
96
+ d_->cbs_ [std::string (" head:" ) + path] = cb;
97
+ return *this ;
98
+ }
99
+
100
+ Router& Router::trace (const std::string &path, const RequestCallback &cb)
101
+ {
102
+ d_->cbs_ [std::string (" trace:" ) + path] = cb;
103
+ return *this ;
104
+ }
105
+
85
106
}
86
107
}
87
108
}
Original file line number Diff line number Diff line change @@ -33,10 +33,13 @@ class Router : public Middleware {
33
33
~Router ();
34
34
35
35
public:
36
- Router& get (const std::string &path, const RequestCallback &cb);
37
- Router& post (const std::string &path, const RequestCallback &cb);
38
- Router& put (const std::string &path, const RequestCallback &cb);
39
- Router& del (const std::string &path, const RequestCallback &cb);
36
+ Router& get (const std::string &path, const RequestCallback &cb);
37
+ Router& post (const std::string &path, const RequestCallback &cb);
38
+ Router& put (const std::string &path, const RequestCallback &cb);
39
+ Router& del (const std::string &path, const RequestCallback &cb);
40
+ Router& opt (const std::string &path, const RequestCallback &cb);
41
+ Router& head (const std::string &path, const RequestCallback &cb);
42
+ Router& trace (const std::string &path, const RequestCallback &cb);
40
43
41
44
public:
42
45
virtual void handle (ContextSptr sp_ctx, const NextFunc &next) override ;
You can’t perform that action at this time.
0 commit comments