mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
* clang-format: Do not use tabs * Ignore clangd cache and compile_commands * NSBlockOperation: Fix memory leak * NSHTTPCookie: Fix expires date parsing * NSHTTPCookie: Release DateFormatter after use * NSOperation: Remove all objects at end of execution * Reimplementation of NSURLSession * NSURLSession: Update expiration dates in test * Update ChangeLog * Fix trivial compiler warning caused by missing import * Import GSDispatch.h for definition of DISPATCH_QUEUE_SERIAL * Import common.h early to avoid header conflict * Fix import order to avoid conflicts and ensure we have correct localisation macro * Check for presence of dispatch_cancel * Cancel timer using dispatch_source_cancel() if dispatch_cancel() is missing. * NSURLSession: Replace dispatch_io with dispatch_source in unit test HTTP server --------- Co-authored-by: hmelder <service@hugomelder.com>
30 lines
711 B
Objective-C
30 lines
711 B
Objective-C
#import <Foundation/NSArray.h>
|
|
#import <Foundation/NSObject.h>
|
|
#import <Foundation/NSURLRequest.h>
|
|
#import <Foundation/NSURLResponse.h>
|
|
|
|
typedef NSData * (^RequestHandlerBlock)(NSURLRequest *);
|
|
|
|
@interface Route : NSObject
|
|
|
|
+ (instancetype)routeWithURL:(NSURL *)url
|
|
method:(NSString *)method
|
|
handler:(RequestHandlerBlock)block;
|
|
|
|
- (NSString *)method;
|
|
- (NSURL *)url;
|
|
- (RequestHandlerBlock)block;
|
|
|
|
- (BOOL)acceptsURL:(NSURL *)url method:(NSString *)method;
|
|
|
|
@end
|
|
|
|
@interface HTTPServer : NSObject
|
|
- initWithPort:(NSInteger)port routes:(NSArray<Route *> *)routes;
|
|
|
|
- (NSInteger)port;
|
|
- (void)resume;
|
|
- (void)suspend;
|
|
|
|
- (void)setRoutes:(NSArray<Route *> *)routes;
|
|
@end
|