當前位置: 首頁>>代碼示例>>Python>>正文


Python hdrs.METH_ANY屬性代碼示例

本文整理匯總了Python中aiohttp.hdrs.METH_ANY屬性的典型用法代碼示例。如果您正苦於以下問題:Python hdrs.METH_ANY屬性的具體用法?Python hdrs.METH_ANY怎麽用?Python hdrs.METH_ANY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在aiohttp.hdrs的用法示例。


在下文中一共展示了hdrs.METH_ANY屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup_instance_subapps

# 需要導入模塊: from aiohttp import hdrs [as 別名]
# 或者: from aiohttp.hdrs import METH_ANY [as 別名]
def setup_instance_subapps(self) -> None:
        self.plugin_routes = {}
        resource = PrefixResource(self.config["server.plugin_base_path"].rstrip("/"))
        resource.add_route(hdrs.METH_ANY, self.handle_plugin_path)
        self.app.router.register_resource(resource) 
開發者ID:maubot,項目名稱:maubot,代碼行數:7,代碼來源:server.py

示例2: view

# 需要導入模塊: from aiohttp import hdrs [as 別名]
# 或者: from aiohttp.hdrs import METH_ANY [as 別名]
def view(path: str, **kwargs: Any) -> WebHandlerDecorator:
    return handle(hdrs.METH_ANY, path, **kwargs) 
開發者ID:maubot,項目名稱:maubot,代碼行數:4,代碼來源:web.py

示例3: __init__

# 需要導入模塊: from aiohttp import hdrs [as 別名]
# 或者: from aiohttp.hdrs import METH_ANY [as 別名]
def __init__(self, http_exception):
        super().__init__(hdrs.METH_ANY, self._handler)
        self._http_exception = http_exception 
開發者ID:aamalev,項目名稱:aiohttp_apiset,代碼行數:5,代碼來源:compat.py

示例4: add_view

# 需要導入模塊: from aiohttp import hdrs [as 別名]
# 或者: from aiohttp.hdrs import METH_ANY [as 別名]
def add_view(
        self, path: str, handler: Type[AbstractView], **kwargs: Any
    ) -> web.AbstractRoute:
        return self.add_route(hdrs.METH_ANY, path, handler, **kwargs) 
開發者ID:hh-h,項目名稱:aiohttp-swagger3,代碼行數:6,代碼來源:swagger.py

示例5: _register

# 需要導入模塊: from aiohttp import hdrs [as 別名]
# 或者: from aiohttp.hdrs import METH_ANY [as 別名]
def _register(self, app: web.Application):
        for route in app.router.routes():
            if issubclass_py37fix(route.handler, web.View) and route.method == METH_ANY:
                for attr in dir(route.handler):
                    if attr.upper() in METH_ALL:
                        view = getattr(route.handler, attr)
                        method = attr
                        self._register_route(route, method, view)
            else:
                method = route.method.lower()
                view = route.handler
                self._register_route(route, method, view)
        app["swagger_dict"] = self.swagger_dict() 
開發者ID:maximdanilchenko,項目名稱:aiohttp-apispec,代碼行數:15,代碼來源:aiohttp_apispec.py

示例6: resolve

# 需要導入模塊: from aiohttp import hdrs [as 別名]
# 或者: from aiohttp.hdrs import METH_ANY [as 別名]
def resolve(self, request, path: str, match_dict: dict):
        method = request.method
        allowed_methods = set()  # type: Set[str]

        if path is None:
            allowed_methods.update(self._routes)
            if method in self._routes:
                route = self._routes[method]
            elif hdrs.METH_ANY in self._routes:
                route = self._routes[hdrs.METH_ANY]
            else:
                return None, allowed_methods
            return UrlMappingMatchInfo(match_dict, route), allowed_methods
        elif not path:
            location = path
            tail = None
        else:
            parts = path.split('/', 1)
            if len(parts) == 2:
                location, tail = parts
            else:
                location = parts[0]
                tail = None

        if location in self._subs:
            match, methods = self._subs[location].resolve(
                request=request,
                path=tail,
                match_dict=match_dict)
            if match is None:
                allowed_methods.update(methods)
            else:
                return match, methods

        for pattern, sublocation in self._patterns:
            m = pattern.match(path)
            if m is not None:
                for key, value in m.groupdict().items():
                    match_dict[key] = parse.unquote(value)

                index = m.end()
                if len(path) > index:
                    if path[index] == '/':
                        index += 1
                    tail = path[index:]
                else:
                    tail = None

                match, methods = sublocation.resolve(
                    request=request, path=tail, match_dict=match_dict)
                if match is None:
                    allowed_methods.update(methods)
                else:
                    return match, methods
        return None, allowed_methods 
開發者ID:aamalev,項目名稱:aiohttp_apiset,代碼行數:57,代碼來源:dispatcher.py

示例7: add_route

# 需要導入模塊: from aiohttp import hdrs [as 別名]
# 或者: from aiohttp.hdrs import METH_ANY [as 別名]
def add_route(
        self,
        method: str,
        path: str,
        handler: Union[_SwaggerHandler, Type[AbstractView]],
        *,
        name: Optional[str] = None,
        expect_handler: Optional[ExpectHandler] = None,
        validate: Optional[bool] = None,
    ) -> web.AbstractRoute:
        if validate is None:
            need_validation: bool = self.validate
        else:
            need_validation = False if not self.validate else validate
        if isinstance(handler, type) and issubclass(handler, AbstractView):
            for meth in hdrs.METH_ALL:
                meth = meth.lower()
                handler_ = getattr(handler, meth, None)
                if handler_ is not None:
                    setattr(
                        handler,
                        meth,
                        self._wrap_handler(
                            meth,
                            path,
                            handler_,
                            is_method=True,
                            validate=need_validation,
                        ),
                    )
        else:
            if method == hdrs.METH_ANY:
                for meth in (
                    hdrs.METH_GET,
                    hdrs.METH_POST,
                    hdrs.METH_PUT,
                    hdrs.METH_PATCH,
                    hdrs.METH_DELETE,
                ):
                    meth = meth.lower()
                    handler = self._wrap_handler(
                        meth, path, handler, is_method=False, validate=need_validation,
                    )
            else:
                handler = self._wrap_handler(
                    method.lower(),
                    path,
                    handler,
                    is_method=False,
                    validate=need_validation,
                )

        return self._app.router.add_route(
            method, path, handler, name=name, expect_handler=expect_handler
        ) 
開發者ID:hh-h,項目名稱:aiohttp-swagger3,代碼行數:57,代碼來源:swagger_docs.py


注:本文中的aiohttp.hdrs.METH_ANY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。