Skip to content

Commit 281b50f

Browse files
committed
HTTPMETHOD: Create Deleter Method
1 parent f0c165b commit 281b50f

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

Tigernet.Samples.RestApi/Resters/UsersRester.cs

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public async ValueTask<object> GetByFilter(EntityQueryOptions<User> model)
2323
return Ok(await userClever.GetAsync(model));
2424
}
2525

26+
[Deleter("/user-remove")]
27+
public async ValueTask<object> Remove()
28+
{
29+
var res = userClever.Delete(2);
30+
return Ok(res);
31+
}
32+
2633
[Getter]
2734
public async ValueTask<object> Get()
2835
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Tigernet.Hosting.Attributes.HttpMethods.Commons;
2+
using Tigernet.Hosting.Exceptions;
3+
using ArgumentNullException = Tigernet.Hosting.Exceptions.ArgumentNullException;
4+
5+
namespace Tigernet.Hosting.Attributes.HttpMethods
6+
{
7+
/// <summary>
8+
/// The 'DeleterAttribute' class used to represent a DELETE HTTP method.
9+
/// </summary>
10+
public class DeleterAttribute : HttpMethodAttribute
11+
{
12+
public DeleterAttribute(string route = null)
13+
: base(route)
14+
{
15+
16+
}
17+
18+
internal override string HttpMethodName
19+
{
20+
get => "DELETE";
21+
}
22+
}
23+
}

src/Tigernet.Hosting/Attributes/HttpMethods/PosterAttribute.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
public class PosterAttribute : HttpMethodAttribute
77
{
88
/// <inheritdoc />
9-
public PosterAttribute(string route = null)
9+
public PosterAttribute(string route = null)
1010
: base(route)
1111
{
12-
1312
}
1413

1514
/// <inheritdoc/>
16-
internal override string HttpMethodName { get => "POST"; }
17-
18-
}
15+
internal override string HttpMethodName
16+
{
17+
get => "POST";
18+
}
19+
}

src/Tigernet.Hosting/Exceptions/ArgumentNullException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ public ArgumentNullException(string argumentName)
66
: base($"The argument '{argumentName}' cannot be null, please provide a valid input!")
77
{
88
}
9-
9+
1010
}

0 commit comments

Comments
 (0)