2

IHttpActionResultRefit を使用して戻る API 呼び出しがあります。

[Patch("/api/userprofile/")]
[Headers("Authorization: Bearer")]
Task<IHttpActionResult> UpdateUserProfile(UserProfile user);  

API 呼び出しを処理するために、別の DLL に別のクラスを作成しました。

public async Task<IHttpActionResult> UpdateUserProfile(UserProfile profile)
{
    if (HttpContext.Current.Request.IsAuthenticated)
    {
        var ups = ApiServiceFactory.GetUserProfileService();
        var result = ups.UpdateUserProfile(profile);

        return result.Result;
    }
    return ???;
}

このクラスは現在 APIController から派生していませんIHttpActionResultResponseMessageHttpResponseMessageOkおよびを試しContent(Status, Message)ました。これらのほとんどは、から派生する必要がありAPIContollerます。1 つのオブジェクトを作成するだけでは、やり過ぎのように思えます。

IHttpActionResultでは、プレーンなクラス/メソッドから 401 のようなものを返すために、 から継承するオブジェクトを作成するにはどうすればよいでしょうか?

4

1 に答える 1