<commit_before>package pl.newicom.dddd.writefront

import akka.actor.Actor
import akka.http.model.{StatusCode, StatusCodes}
import akka.pattern.ask
import akka.util.Timeout
import pl.newicom.dddd.aggregate.Command
import pl.newicom.dddd.delivery.protocol.Processed

import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

trait CommandHandler extends GlobalOfficeClientSupport {
  this: Actor =>

  def handle(officeName: String, command: Command)(implicit timeout: Timeout, ec: ExecutionContext): Future[StatusCode] = {
    office(officeName).ask(command).flatMap {
      case Processed(Success(_)) => Future(StatusCodes.OK)
      case Processed(Failure(_)) => Future(StatusCodes.InternalServerError)
    }
  }
}<commit_msg>fix http response marshaling (CommandHandler (write-front))<commit_after>package pl.newicom.dddd.writefront

import akka.actor.Actor
import akka.pattern.ask
import akka.util.Timeout
import pl.newicom.dddd.aggregate.Command
import pl.newicom.dddd.delivery.protocol.Processed

import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success, Try}

trait CommandHandler extends GlobalOfficeClientSupport {
  this: Actor =>

  def handle(officeName: String, command: Command)(implicit timeout: Timeout, ec: ExecutionContext): Future[Try[String]] = {
    office(officeName).ask(command).flatMap {
      case Processed(Success(_)) => Future(Success("Command processed. Thank you!"))
      case Processed(Failure(ex)) => Future(Failure(ex))
    }
  }
}
{'fraction_non_alphanumeric': 0.11533420707732635, 'fraction_numerical': 0.0, 'mean_word_length': 5.697368421052632, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6747403', 'n_tokens_mistral': 469, 'n_tokens_neox': 463, 'n_words': 94}