{"id":31104739,"url":"https://github.com/uisawara/usimplehttpserver","last_synced_at":"2026-05-15T18:32:51.741Z","repository":{"id":314373160,"uuid":"1055227108","full_name":"uisawara/usimplehttpserver","owner":"uisawara","description":"SimpleHttpServer for Unity. UnityアプリにシンプルなAPIサーバー機能を持たせるためのpackage","archived":false,"fork":false,"pushed_at":"2025-10-15T23:55:08.000Z","size":165,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-16T11:54:00.577Z","etag":null,"topics":["api","csharp","gauge","openapi","server","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uisawara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-12T00:53:07.000Z","updated_at":"2025-10-15T23:55:11.000Z","dependencies_parsed_at":"2025-09-12T04:49:27.954Z","dependency_job_id":"81f2e17c-7e6d-498e-ab4f-57edbf7870cf","html_url":"https://github.com/uisawara/usimplehttpserver","commit_stats":null,"previous_names":["uisawara/usimplehttpserver"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/uisawara/usimplehttpserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uisawara%2Fusimplehttpserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uisawara%2Fusimplehttpserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uisawara%2Fusimplehttpserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uisawara%2Fusimplehttpserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uisawara","download_url":"https://codeload.github.com/uisawara/usimplehttpserver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uisawara%2Fusimplehttpserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33074840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","csharp","gauge","openapi","server","unity"],"created_at":"2025-09-17T03:41:12.174Z","updated_at":"2026-05-15T18:32:51.721Z","avatar_url":"https://github.com/uisawara.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# usimplehttpserver : SimpleHttpServer for Unity\n\nNote: This document is a machine translation of the original Japanese README and may contain inaccuracies.\n\n!! Currently experimental !!\nThis package adds a simple HTTP API server capability to your Unity application.\n\nBy exposing app APIs, you can flexibly combine and use your app with other applications. For example:\n- Operate or query the app from a web browser, curl, etc.\n- Use for API-based end-to-end automated tests (a Gauge sample is included)\n- Generate documentation by fetching the API specification from the `openapi.yml` endpoint\n- Provide information to AI tools from the `openapi.yml` endpoint to make AI-driven app control easier\n- Assign API call buttons to devices such as Elgato Stream Deck to trigger app shortcuts\n\n## Concept\n\n- Expose existing Unity app code as APIs with simple steps\n- Gain interoperability with other applications through APIs\n- Leverage existing web development tools and practices via OpenAPI.yml\n\n**Non-goals**\n\n- Keep it simple. Focus only on API server functionality; do not aim to be a general-purpose web server with static files, template engines, and other features.\n- Do not aim for a security level suitable for publishing APIs directly to the internet.\n  - Primarily intended for local use by the user on their own PC.\n- Do not aim for full compliance with requests from web browsers; omit optional parts wherever possible.\n\n```mermaid\ngraph LR\n\nsubgraph UnityApp\ns\nc\nsvr\nend\n\ns[[c#-routing-attribute]] --\u003e|add API spec metadata| c[c# code] --\u003e|export| o[OpenAPI.yml]\no --\u003e|input| og[openapi-generator]\no --\u003e|input| rd[redoc]\n\nsvr[[C#-api-server-script]] -.-\u003e|auto enumeration| s\n\nclient --\u003e|http| svr\n\nsubgraph ExternalTools\nog\nrd\nend\n```\n\n## Installation\n\n### dependencies\n\nPlease import the following first:\n\n- com.cysharp.unitask\n  - Refer to the official repository `https://github.com/Cysharp/UniTask.git` for installation.\n\n- com.unity.nuget.newtonsoft-json\n  - Open Package Manager and install by name: `com.unity.nuget.newtonsoft-json`.\n\n\n### upm\n\nInstall this package from Package Manager via “Install package from git URL...” using the following URL:\n\n```\nhttps://github.com/uisawara/usimplehttpserver.git?path=Assets/UnityPackages/mmzkworks.usimplehttpserver\n```\n\n## Code examples\n\n### Start/Stop the server\n\n```c#\npublic sealed class SimpleHttpServerBehaviour : MonoBehaviour\n{\n    [SerializeField] private int port = 8080;\n    private SimpleHttpServer? server;\n\n    private void Awake()\n    {\n        DontDestroyOnLoad(gameObject);\n\n        // Start HttpServer\n        server = new SimpleHttpServer(port);\n        // Register controllers based on attributes (routing configuration)\n        server.RegisterControllersFrom(Assembly.GetExecutingAssembly());\n        server.Start();\n    }\n\n    private void OnDestroy()\n    {\n        // Stop HttpServer\n        server?.Stop();\n        server = null;\n    }\n}\n```\n\n### URI routing\n\n- Define routes via attributes.\n- URL parameters are bound to method parameters.\n\n```c#\n[RoutePrefix(\"/api\")]\npublic sealed class DemoController\n{\n    // GET /api/echo/hello?times=3 -\u003e \"hellohellohello\"\n    [HttpGet(\"/echo/{text}\")]\n    public string Echo(string text, int times = 1)\n    {\n        return string.Concat(Enumerable.Repeat(text, Math.Max(1, times)));\n    }\n\n    // GET /api/add/12/30 -\u003e { \"a\":12, \"b\":30, \"sum\":42 }\n    [HttpGet(\"/add/{a}/{b}\")]\n    public object Add(int a, int b)\n    {\n        return new { a, b, sum = a + b };\n    }\n\n    // POST /api/users  Body: {\"name\":\"Alice\",\"age\":20}\n    [HttpPost(\"/users\")]\n    public User CreateUser([FromBody] User req)\n    {\n        return new User { Id = Guid.NewGuid(), Name = req.Name, Age = req.Age };\n    }\n\n    // GET /api/users/{id}\n    [HttpGet(\"/users/{id}\")]\n    public User GetUser(Guid id)\n    {\n        return new User { Id = id, Name = \"Sample\", Age = 42 };\n    }\n}\n\npublic sealed class User\n{\n    public Guid Id { get; set; }\n    public string Name { get; set; } = \"\";\n    public int Age { get; set; }\n}\n```\n\n## Sample code\n\nSample code is included with the UPM package.\nYou can import it from Package Manager in the Unity Editor.\n\n### ApplicationStateApiSample\n\nIncludes several sample API implementations.\n\n| API Endpoint | Response                                                   |\n| ------------ | ---------------------------------------------------------- |\n| /api/echo/{text}  | Returns the provided text as an echo.                  |\n| /api/state        | Returns the full application state in JSON.           |\n| /api/state/{key}  | Returns the application state in JSON for the specified category.\u003cbr /\u003eYou can use the following for key:\u003cbr /\u003eapplication: basic app info\u003cbr /\u003eenvironments: runtime environment variables and command-line arguments\u003cbr /\u003eruntime: runtime info |\n\n### OpenApi endpoint\n\nBy enabling this, you can obtain the API specification in OpenAPI Specification format via the API.\nThe endpoint is `/openapi.yml`.\n\n### gauge sample\n\nThis is sample code that uses the test automation framework [gauge](https://gauge.org/) to run API tests against a built binary.\n- Launch the built binary with a command-line argument specifying the server listen port\n- Access the API endpoints and validate responses\n\n## API documentation generation (openapi.yml export)\n\nYou can export OpenAPI YAML to make creating API documents easier.\n\n### How to use\n\n- From the Unity Editor menu, select Tools/uSimpleHttpServer/Generate OpenAPI YAML to output `openapi.yml`.\n- On first run, `Assets/Settings/OpenApiExportSettings` will be created.\n  - Edit this file to change export settings.\n\n## About AI Generation\n\n- This repository contains code generated by AI.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuisawara%2Fusimplehttpserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuisawara%2Fusimplehttpserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuisawara%2Fusimplehttpserver/lists"}