Working project
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dart_frog/dart_frog.dart';
|
||||
import 'package:new_backend/shrink_ray.dart';
|
||||
|
||||
Future<Response> onRequest(RequestContext context, String urlPath) async {
|
||||
switch (context.request.method) {
|
||||
case HttpMethod.put:
|
||||
case HttpMethod.delete:
|
||||
case HttpMethod.head:
|
||||
case HttpMethod.options:
|
||||
case HttpMethod.patch:
|
||||
case HttpMethod.post:
|
||||
return Response(statusCode: 404);
|
||||
case HttpMethod.get:
|
||||
final maybeUrl = shrunkUrls[urlPath];
|
||||
switch (maybeUrl) {
|
||||
case null:
|
||||
return Response(statusCode: 404);
|
||||
default:
|
||||
return Response(statusCode: 302, headers: {'Location': maybeUrl});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user