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)
4545 case Method::kPut : prefix = " put:" ; break ;
4646 case Method::kPost : prefix = " post:" ; break ;
4747 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 ;
4851 default :;
4952 }
5053
@@ -82,6 +85,24 @@ Router& Router::del(const std::string &path, const RequestCallback &cb)
8285 return *this ;
8386}
8487
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+
85106}
86107}
87108}
Original file line number Diff line number Diff line change @@ -33,10 +33,13 @@ class Router : public Middleware {
3333 ~Router ();
3434
3535 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);
4043
4144 public:
4245 virtual void handle (ContextSptr sp_ctx, const NextFunc &next) override ;
You can’t perform that action at this time.
0 commit comments