Return 404 vs. 500 for invalid category
This commit is contained in:
parent
ba6403dfef
commit
aa3ee239f6
|
@ -118,14 +118,11 @@ let pageOfCategorizedPosts slugAndPage : HttpHandler = fun next ctx -> task {
|
||||||
let conn = ctx.Conn
|
let conn = ctx.Conn
|
||||||
match parseSlugAndPage webLog slugAndPage with
|
match parseSlugAndPage webLog slugAndPage with
|
||||||
| Some pageNbr, slug, isFeed ->
|
| Some pageNbr, slug, isFeed ->
|
||||||
let allCats = CategoryCache.get ctx
|
match CategoryCache.get ctx |> Array.tryFind (fun cat -> cat.slug = slug) with
|
||||||
let cat = allCats |> Array.find (fun cat -> cat.slug = slug)
|
| Some cat when isFeed ->
|
||||||
if isFeed then
|
|
||||||
return! Feed.generate (Feed.CategoryFeed ((CategoryId cat.id), $"category/{slug}/{webLog.rss.feedName}"))
|
return! Feed.generate (Feed.CategoryFeed ((CategoryId cat.id), $"category/{slug}/{webLog.rss.feedName}"))
|
||||||
(defaultArg webLog.rss.itemsInFeed webLog.postsPerPage) next ctx
|
(defaultArg webLog.rss.itemsInFeed webLog.postsPerPage) next ctx
|
||||||
else
|
| Some cat ->
|
||||||
let allCats = CategoryCache.get ctx
|
|
||||||
let cat = allCats |> Array.find (fun cat -> cat.slug = slug)
|
|
||||||
// Category pages include posts in subcategories
|
// Category pages include posts in subcategories
|
||||||
match! Data.Post.findPageOfCategorizedPosts webLog.id (getCategoryIds slug ctx) pageNbr webLog.postsPerPage
|
match! Data.Post.findPageOfCategorizedPosts webLog.id (getCategoryIds slug ctx) pageNbr webLog.postsPerPage
|
||||||
conn with
|
conn with
|
||||||
|
@ -139,6 +136,7 @@ let pageOfCategorizedPosts slugAndPage : HttpHandler = fun next ctx -> task {
|
||||||
hash.Add ("slug", slug)
|
hash.Add ("slug", slug)
|
||||||
return! themedView "index" next ctx hash
|
return! themedView "index" next ctx hash
|
||||||
| _ -> return! Error.notFound next ctx
|
| _ -> return! Error.notFound next ctx
|
||||||
|
| None -> return! Error.notFound next ctx
|
||||||
| None, _, _ -> return! Error.notFound next ctx
|
| None, _, _ -> return! Error.notFound next ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"hostname": "data02.bitbadger.solutions",
|
"hostname": "data02.bitbadger.solutions",
|
||||||
"database": "myWebLog_dev"
|
"database": "myWebLog_dev"
|
||||||
},
|
},
|
||||||
"Generator": "myWebLog 2.0-alpha17",
|
"Generator": "myWebLog 2.0-alpha18",
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"MyWebLog.Handlers": "Debug"
|
"MyWebLog.Handlers": "Debug"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user