using Microsoft.AspNetCore.Http;

namespace Modules.User.Application;

public class UserMiddleware
{
    private readonly RequestDelegate _next;

    public UserMiddleware(RequestDelegate next)
    {
        _next = next;
    }

    public async Task Invoke(HttpContext httpContext, UserContext userContext)
    {
        userContext.SetUserInfo(httpContext);
        userContext.SetUserAgent(httpContext);
        userContext.SetRefreshToken(httpContext);
        userContext.SetClientIp(httpContext);
        await _next(httpContext);
    }

}
