Logo: Relish

  1. Sign in

Project: Garret

Typed Middleware

  • @developer

As a developer of linked data applications you often find yourself in a
situation where you have to implement a specific behaviour for a specific
rdf:type. Garret allows just that.

By using typed middlewares one is able to implement HTTP request handlers
that only get triggered if a resource is an instance of a specific class.
Moreover they will be executed according to the hierarchy of the classes
defined by rdfs:subClassOf.

Scenarios
Execution of a typed middleware

Each middleware implements a specific rdf:type. If the resource that
was requested from the server is an instance of this class it will be
executed.

Given
a request for an instance of ex:Type
And
a middleware that implements ex:Type
Then
the middleware should be executed
Execution of a supertyped middleware

If a middleware implements a supertype of a requested resource it will
be executed.

Given
a request for an instance of ex:Type1
And
a middleware that implements ex:Type2
And
ex:Type1 is a subclass of ex:Type2
Then
the middleware should be executed
Hierarchical execution of typed middlewares

If there is more than one typed middleware on the stack they will be
executed according the hierarchy of the implemented types.

Given
a request for an instance of ex:Type1
And
a middleware mid1 that implements ex:Type1
And
a middleware mid2 that implements ex:Type2
And
ex:Type1 is a subclass of ex:Type2
Then
mid1 should be executed before mid2
Non-execution of a typed middleware

A middleware that implements a specific type won't be executed
for requests to resources that aren't instances of that type or of a
subtype.

Given
a request for an instance of ex:Type1
And
a middleware that implements ex:Type2
And
ex:Type1 is not the same as ex:Type2
And
ex:Type1 is not a subtype of ex:Type2
Then
the middleware should not be executed

Last published over 6 years ago by Niclas Hoyer.