Files
SpeedTest/src/net/http/HttpMethod.ts
Alexander Zinn 21b9e52f40 Add frontend speed test application and server setup
* Introduced a new HTML frontend for network speed testing with a responsive UI
* Implemented backend server functionality to serve the frontend and handle speed test APIs
* Added speed test logic for downloading and uploading data, including progress tracking and result validation
* Created README-SPEEDTEST.md for documentation on application architecture, setup, and usage.
* Updated package.json to include necessary scripts and dependencies for development and testing
2025-11-21 04:56:18 -05:00

53 lines
1.2 KiB
TypeScript

import {assertUnreachable} from '@techniker-me/tools';
export enum HttpMethod {
GET = 0,
POST = 1,
PUT = 2,
DELETE = 3,
PATCH = 4,
OPTIONS = 5
}
export type HttpMethodType = keyof typeof HttpMethod;
export class HttpMethodMapping {
public static convertHttpMethodTypeToHttpMethod(method: HttpMethodType): HttpMethod {
switch (method) {
case 'GET':
return HttpMethod.GET;
case 'POST':
return HttpMethod.POST;
case 'PUT':
return HttpMethod.PUT;
case 'DELETE':
return HttpMethod.DELETE;
case 'PATCH':
return HttpMethod.PATCH;
case 'OPTIONS':
return HttpMethod.OPTIONS;
default:
assertUnreachable(method);
}
}
public static convertHttpMethodToHttpMethodType(method: HttpMethod): HttpMethodType {
switch (method) {
case HttpMethod.GET:
return 'GET';
case HttpMethod.POST:
return 'POST';
case HttpMethod.PUT:
return 'PUT';
case HttpMethod.DELETE:
return 'DELETE';
case HttpMethod.PATCH:
return 'PATCH';
case HttpMethod.OPTIONS:
return 'OPTIONS';
default:
assertUnreachable(method);
}
}
}