|
|
@ -12,7 +12,7 @@ namespace Volo.Abp.Http.DynamicProxying |
|
|
public class RegularTestController : AbpController, IRegularTestController |
|
|
public class RegularTestController : AbpController, IRegularTestController |
|
|
{ |
|
|
{ |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("increment/{value}")] |
|
|
[Route("increment/{value}")] //full URL: .../api/regular-test-controller/increment/{value}
|
|
|
public int IncrementValue(int value) |
|
|
public int IncrementValue(int value) |
|
|
{ |
|
|
{ |
|
|
return value + 1; |
|
|
return value + 1; |
|
|
@ -31,5 +31,99 @@ namespace Volo.Abp.Http.DynamicProxying |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException("This is an error message!"); |
|
|
throw new UserFriendlyException("This is an error message!"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
[Route("post-with-header-and-qs")] |
|
|
|
|
|
public Task<string> PostValueWithHeaderAndQueryStringAsync([FromHeader] string headerValue, [FromQuery] string qsValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(headerValue + "#" + qsValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
[Route("post-with-body")] |
|
|
|
|
|
public Task<string> PostValueWithBodyAsync([FromBody] string bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
[Route("post-object-with-body")] |
|
|
|
|
|
public Task<Car> PostObjectWithBodyAsync([FromBody] Car bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
[Route("post-object-with-query")] |
|
|
|
|
|
public Task<Car> PostObjectWithQueryAsync( Car bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
|
[Route("post-object-with-url/bodyValue")] |
|
|
|
|
|
public Task<Car> GetObjectWithUrlAsync(Car bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
|
[Route("post-object-and-id-with-url/{id}")] |
|
|
|
|
|
public Task<Car> GetObjectandIdAsync(int id, [FromBody] Car bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
bodyValue.Year = id; |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
|
[Route("post-object-and-id-with-url-and-query/{id}")] |
|
|
|
|
|
public Task<Car> GetObjectAndIdWithQueryAsync(int id, Car bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
bodyValue.Year = id; |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPut] |
|
|
|
|
|
[Route("put-with-body")] |
|
|
|
|
|
public Task<string> PutValueWithBodyAsync([FromBody] string bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPut] |
|
|
|
|
|
[Route("put-with-header-and-qs")] |
|
|
|
|
|
public Task<string> PutValueWithHeaderAndQueryStringAsync([FromHeader] string headerValue, [FromQuery] string qsValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(headerValue + "#" + qsValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPatch] |
|
|
|
|
|
[Route("patch-with-header-and-qs")] |
|
|
|
|
|
public Task<string> PatchValueWithHeaderAndQueryStringAsync([FromHeader] string headerValue, [FromQuery] string qsValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(headerValue + "#" + qsValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPatch] |
|
|
|
|
|
[Route("patch-with-body")] |
|
|
|
|
|
public Task<string> PatchValueWithBodyAsync([FromBody] string bodyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(bodyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpDelete] |
|
|
|
|
|
[Route("delete-by-id")] |
|
|
|
|
|
public Task<int> DeleteByIdAsync(int id) |
|
|
|
|
|
{ |
|
|
|
|
|
return Task.FromResult(id + 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class Car |
|
|
|
|
|
{ |
|
|
|
|
|
[FromQuery] |
|
|
|
|
|
public int Year { get; set; } |
|
|
|
|
|
[FromQuery] |
|
|
|
|
|
public string Model { get; set; } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |