Пример #1
0
    def process_request(self, req: Request, resp: Response):
        self.context.logger.debug(f'process_request: {req.method} {req.path}')

        if req.method == 'POST':
            if req.path == '/login':
                if req.content_type != 'application/json':
                    raise UnsupportedMediaTypeMalformed(
                        detail=
                        f'{req.content_type} is an unsupported media type for {req.path}'
                    )
            elif req.path == '/notifications':
                if req.content_type == 'text/plain; charset=UTF-8':
                    # We know the body is json, set the correct content type
                    req.content_type = 'application/json'
            elif req.content_type != 'application/scim+json':
                raise UnsupportedMediaTypeMalformed(
                    detail=f'{req.content_type} is an unsupported media type')