Class AddRequestProperties
- java.lang.Object
-
- org.restheart.mongodb.interceptors.AddRequestProperties
-
- All Implemented Interfaces:
ConfigurablePlugin,ExchangeTypeResolver<MongoRequest,MongoResponse>,Interceptor<MongoRequest,MongoResponse>,MongoInterceptor,Plugin
public class AddRequestProperties extends Object implements MongoInterceptor
- Author:
- Andrea Di Cesare <andrea@softinstigate.com> addRequestProperties adds properties to write requests on documents of collections that have the following metadata: { "addRequestProperties": { "log": [ "userName", "remoteIp" ] } } ] } This is an example on how to refactor an old (before v5) Transformer as an Interceptor. The Transformer was applied using collection metatada; here the resolve() method checks if the collection properties obtained via the method request.getCollectionProps() contains the expected metadata object. the addRequestProperties metadata object can be either an array of strings, each specifiying the properties to add, or an object with a single property, as in the above example where the properties are added to the request in the nested "log" subdocument. the properties that can be added are: userName, userRoles, epochTimeStamp, dateTime, localIp, localPort, localServerName, queryString, relativePath, remoteIp, requestMethod, requestProtocol
-
-
Constructor Summary
Constructors Constructor Description AddRequestProperties()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandle(MongoRequest request, MongoResponse response)booleanresolve(MongoRequest request, MongoResponse response)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.restheart.plugins.ExchangeTypeResolver
requestType, responseType
-
-
-
-
Method Detail
-
handle
public void handle(MongoRequest request, MongoResponse response) throws Exception
- Specified by:
handlein interfaceInterceptor<MongoRequest,MongoResponse>- Throws:
Exception
-
resolve
public boolean resolve(MongoRequest request, MongoResponse response)
- Specified by:
resolvein interfaceInterceptor<MongoRequest,MongoResponse>
-
-