IHttpActionResult
Refit を使用して戻る 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 から派生していませんIHttpActionResult
。ResponseMessage
、HttpResponseMessage
、Ok
およびを試しContent(Status, Message)
ました。これらのほとんどは、から派生する必要がありAPIContoller
ます。1 つのオブジェクトを作成するだけでは、やり過ぎのように思えます。
IHttpActionResult
では、プレーンなクラス/メソッドから 401 のようなものを返すために、 から継承するオブジェクトを作成するにはどうすればよいでしょうか?