Skip to content

Commit 4831d20

Browse files
committed
Use new methodNotAllowedHandler
1 parent d925c73 commit 4831d20

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

app/lib/frontend/handlers/documentation.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ import '../../shared/urls.dart';
2525
Future<shelf.Response> documentationHandler(shelf.Request request) async {
2626
final requestMethod = request.method.toUpperCase();
2727
if (requestMethod != 'HEAD' && requestMethod != 'GET') {
28-
// TODO: Should probably be "method not supported"!
29-
return notFoundHandler(request);
28+
return methodNotAllowedHandler(request);
3029
}
3130

3231
final docFilePath = parseRequestUri(request.requestedUri);

app/lib/shared/handlers.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ shelf.Response notFoundHandler(
101101
return htmlResponse(body, status: 404, headers: headers);
102102
}
103103

104+
shelf.Response methodNotAllowedHandler(
105+
shelf.Request request, {
106+
Map<String, Object>? headers,
107+
}) {
108+
return shelf.Response(405, body: 'Method Not Allowed', headers: headers);
109+
}
110+
104111
shelf.Response rejectRobotsHandler(shelf.Request request) =>
105112
shelf.Response.ok('User-agent: *\nDisallow: /\n');
106113

0 commit comments

Comments
 (0)