Purpose-Context-awareness is an essential property of any pervasive system perceiving its environment. Such a system captures and processes context, i.e. the features describing the relevant aspects of environment state and user behaviour. However, development of these systems still requires solving a number of research and engineering challenges. The purpose of this paper is to propose perception framework, a RESTful middleware which simplifies and accelerates the development of pervasive systems. Perception framework allows constructing services' application logic using rules and context. Moreover, it collects sensor data and produces the context information that is required for the rules. The authors present the architecture, design, complete implementation, and prototype-based verification of perception framework. Design/methodology/approach-Development of context-aware services is achieved with a novel architecture supporting building of the logic of web services using rules which directly manipulate the available elementary context represented with the Web Ontology Language (OWL) ontology. These rules are described using the Rule Interchange Format (RIF) with support for different rule languages. The implementation of this framework is aligned with RESTful principles, providing a lightweight and flexible solution for large-scale context-aware systems. Findings-The fully implemented prototype verifies the feasibility of constructing the logic of context-aware web services with the rules supported by perception framework. Originality/value-The contributions of this paper include: the requirement specification for a generic context-aware pervasive middleware; and the design and implementation of the framework (i.e. perception framework) supporting the development of context-aware web services. The perception framework includes a generic rule-based reasoner allowing developers to use several RIF-compliant rule description languages.