Skip to main content
Glama
PressButtonHandler.swift864 B
import Foundation import FlyingFox import os import XCTest import Network @MainActor struct PressButtonHandler: HTTPHandler { private let logger = Logger( subsystem: Bundle.main.bundleIdentifier!, category: String(describing: Self.self) ) func handleRequest(_ request: HTTPRequest) async throws -> HTTPResponse { guard let requestBody = try? await JSONDecoder().decode(PressButtonRequest.self, from: request.bodyData) else { return AppError(type: .precondition, message: "Incorrect request body for PressButton Handler").httpResponse } switch requestBody.button { case .home: XCUIDevice.shared.press(.home) case .lock: XCUIDevice.shared.perform(NSSelectorFromString("pressLockButton")) } return HTTPResponse(statusCode: .ok) } }

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