/finatra-request-local-time

RequestLocalTime to get a unique `requestedAt` throughout a request-response lifetime.

Primary LanguageScala

finatra-request-local-time

Build Status

Provides RequestLocalTime.current.requestedAt , which is a consistent timestamp among a request-response lifetime.

Usage

See #1 for an example usage.

Setting SetRequestLocalTimeFilter

import com.github.laysakura.requestlocaltime.filters.SetRequestLocalTimeFilter
import com.twitter.finatra.thrift.ThriftServer
import com.twitter.finatra.thrift.routing.ThriftRouter

class YourServer extends ThriftServer
{
  // ...

  override def configureThrift(router: ThriftRouter) {
    router
      // other filters ...
      .filter[SetRequestLocalTimeFilter]
      .add[YourController]
  }
}

Accessing RequestLocalTime.current.requestedAt

It can be accessed from anywhere if the code path is reached by a request.