{authorId:int} instead of {authorId} (#2822)

// its better to use {authorId:int} instead of just {authorId}
// wrong {authorId} will produce a 400 error with error message
// wrong {authorId:int} will produce a 404 error

Since the publish date route is limited to a couple of formats, I assume you're of the type to prefer to control what type of error is shown to the resource user.
pull/2801/merge
H Masri 2017-02-24 05:59:22 +08:00 committed by Rick Anderson
parent da607bb672
commit a47db5277c
1 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
[Route("~api/authors/{authorId}/books")]
[Route("~/api/authors/{authorId:int}/books")]
public IQueryable<BookDto> GetBooksByAuthor(int authorId)
{
return db.Books.Include(b => b.Author)
.Where(b => b.AuthorId == authorId)
.Select(AsBookDto);
}
}