mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #913, refine server utility
This commit is contained in:
parent
ca9f0bdb1e
commit
a20e2c3ef6
15 changed files with 222 additions and 244 deletions
|
@ -560,24 +560,18 @@ void SrsHttpServeMux::unhijack(ISrsHttpMatchHijacker* h)
|
|||
hijackers.erase(it);
|
||||
}
|
||||
|
||||
int SrsHttpServeMux::handle(std::string pattern, ISrsHttpHandler* handler)
|
||||
srs_error_t SrsHttpServeMux::handle(std::string pattern, ISrsHttpHandler* handler)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
srs_assert(handler);
|
||||
|
||||
if (pattern.empty()) {
|
||||
ret = ERROR_HTTP_PATTERN_EMPTY;
|
||||
srs_error("http: empty pattern. ret=%d", ret);
|
||||
return ret;
|
||||
return srs_error_new(ERROR_HTTP_PATTERN_EMPTY, "empty pattern");
|
||||
}
|
||||
|
||||
if (entries.find(pattern) != entries.end()) {
|
||||
SrsHttpMuxEntry* exists = entries[pattern];
|
||||
if (exists->explicit_match) {
|
||||
ret = ERROR_HTTP_PATTERN_DUPLICATED;
|
||||
srs_error("http: multiple registrations for %s. ret=%d", pattern.c_str(), ret);
|
||||
return ret;
|
||||
return srs_error_new(ERROR_HTTP_PATTERN_DUPLICATED, "pattern=%s exists", pattern.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,7 +626,7 @@ int SrsHttpServeMux::handle(std::string pattern, ISrsHttpHandler* handler)
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return srs_success;
|
||||
}
|
||||
|
||||
bool SrsHttpServeMux::can_serve(ISrsHttpMessage* r)
|
||||
|
|
|
@ -426,7 +426,7 @@ public:
|
|||
public:
|
||||
// Handle registers the handler for the given pattern.
|
||||
// If a handler already exists for pattern, Handle panics.
|
||||
virtual int handle(std::string pattern, ISrsHttpHandler* handler);
|
||||
virtual srs_error_t handle(std::string pattern, ISrsHttpHandler* handler);
|
||||
// whether the http muxer can serve the specified message,
|
||||
// if not, user can try next muxer.
|
||||
virtual bool can_serve(ISrsHttpMessage* r);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue