RESTful API & Middleware Design Flashcards
7 cards from real CSI practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 RESTful API & Middleware Design flashcards as text
Which HTTP status code should a REST API return when a client submits a request with a malformed JSON body?
Answer: 400 Bad Request
400 Bad Request is returned when the server cannot parse the request due to malformed syntax, including invalid JSON.
In REST API design, what is the purpose of the ETag response header?
Answer: To provide a version identifier for cache validation
ETag provides a hash or version token that clients send in If-None-Match headers to enable conditional requests and cache revalidation.
A middleware component in an API gateway intercepts all inbound requests. Which design pattern does this exemplify?
Answer: Chain of Responsibility pattern
Chain of Responsibility passes requests along a chain of handlers (middleware), where each can process or forward the request.
When designing a REST API for paginated collections, which approach best aligns with REST constraints?
Answer: Include pagination metadata in response headers like Link
Using Link headers (RFC 5988) keeps pagination controls hypermedia-driven and stateless, consistent with REST principles.
Which HTTP method is idempotent but NOT safe according to REST semantics?
Answer: PUT
PUT is idempotent (multiple identical calls produce the same result) but not safe because it modifies server state.
What is the primary role of a message broker middleware like RabbitMQ in a system integration scenario?
Answer: Decoupling producers and consumers through asynchronous message queuing
Message brokers decouple services by allowing producers to publish messages independently of when consumers process them.
In an API versioning strategy, what is a key disadvantage of embedding the version in the URL path (e.g., /v1/users)?
Answer: It breaks the REST principle that URIs should identify resources, not versions
URI-based versioning violates REST purity because the same resource should have a stable URI regardless of representation version.