on-internet
← Community

Where should the cookie-setting logic live, in the controller or the service layer, when it depends on configuration?

Stack Overflow ·

I used to set a cookie directly in the controller, deriving its value from the incoming request. I've changed it so the value now comes from a configuration property instead. In our architecture, configuration is supposed to be loaded in the service layer. Does that mean the cookie-setting logic should move into the service layer, with the controller only attaching the result to the response? Or can the controller keep setting the cookie and just call the service to get the configured value?

Comments

Sign in or sign up to comment and upvote.

No comments yet.