Skip to content

Instantly share code, notes, and snippets.

@vbilopav
Last active September 2, 2015 08:15
Show Gist options
  • Save vbilopav/6bc63806fe4071be5fd7 to your computer and use it in GitHub Desktop.
Save vbilopav/6bc63806fe4071be5fd7 to your computer and use it in GitHub Desktop.
public class MyRequestResponseFactory : IMyRequestResponseFactory
{
public TResponse ProcessRequest<TResponse>(Request request, Func<TResponse> handler)
where TResponse : Response, new()
{
try
{
// Validacija request poruke (ovisno o tipu)
// Autentifikacija korisnika - podaci iz request poruke
// Autorizacija korisnika - podaci iz request poruke
// Postavljanje thread globalizacije - podaci iz request poruke
// konstruiranje response poruke
var msg = handler();
// Dodatna procesiranja response, npr, spremanje u bazu...
// vrati response
return msg;
}
catch (Exception exception)
{
// log exception
var logId = Log.Error(exception);
//Konstruiranje poruke s greškom, ErrorInfo je user friendly string koji sadrži logId
return new Response(ErrorInfo(logId)) as TResponse;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment