Skip to content

Expose CQRS constructor on JsonApiController #205

Closed
@jaredcnance

Description

@jaredcnance

Users should be allowed to expose all endpoints, but define the allowable actions by the provided constructor arguments.

So, instead of:

public class TodoItemsController : BaseJsonApiController<TodoItem>
{
    public TodoItemsController(
        IJsonApiContext jsonApiContext,
        ICreateService<TodoItem> create) 
        : base(jsonApiContext, create: create)
    { }

    [HttpPost]
    public override async Task<IActionResult> PostAsync([FromBody] T entity) => await base.PostAsync(entity);
}

you can:

public class TodoItemsController : JsonApiController<TodoItem>
{
    public TodoItemsController(
        IJsonApiContext jsonApiContext,
        ICreateService<TodoItem> create) 
        : base(jsonApiContext, create: create)
    { }
}

all other methods should return HTTP 405 Method Not Allowed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions