Skip to main content
Glama
SwipeRouteHandlerV2.swift2 kB
import FlyingFox import XCTest import os @MainActor struct SwipeRouteHandlerV2: HTTPHandler { private let logger = Logger( subsystem: Bundle.main.bundleIdentifier!, category: String(describing: Self.self) ) func handleRequest(_ request: FlyingFox.HTTPRequest) async throws -> FlyingFox.HTTPResponse { guard let requestBody = try? await JSONDecoder().decode(SwipeRequest.self, from: request.bodyData) else { return AppError(type: .precondition, message: "incorrect request body provided for swipe request v2").httpResponse } if (requestBody.duration < 0) { return AppError(type: .precondition, message: "swipe duration can not be negative").httpResponse } do { try await swipePrivateAPI(requestBody) return HTTPResponse(statusCode: .ok) } catch let error { return AppError(message: "Swipe v2 request failure. Error: \(error.localizedDescription)").httpResponse } } func swipePrivateAPI(_ request: SwipeRequest) async throws { let (width, height) = ScreenSizeHelper.physicalScreenSize() let startPoint = ScreenSizeHelper.orientationAwarePoint( width: width, height: height, point: request.start ) let endPoint = ScreenSizeHelper.orientationAwarePoint( width: width, height: height, point: request.end ) let description = "Swipe (v2) from \(request.start) to \(request.end) with \(request.duration) duration" logger.info("\(description)") let eventTarget = EventTarget() try await eventTarget.dispatchEvent(description: description) { EventRecord(orientation: .portrait) .addSwipeEvent( start: startPoint, end: endPoint, duration: request.duration ) } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mobile-dev-inc/Maestro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server