wails
wails copied to clipboard
[V3] Refactor binding transport layer
Description
This PR refactors binding layer + provides new Transport abstraction that allow user to replace default transport with WebSockets, custom protocols, or any other transport mechanism.
Motivation:
- System bindings uses HTTP transport for both request and response, but services bindings utilize JS callbacks
- Some usage scenarios doesn't allow to use HTTP transport (e.g. running external page with https and access to bindings)
- There is proposal to move default transport to Websocket (this needs continues investigation to identify how provide security guarantees)
List of changes:
- Drops JS callbacks for bindings in HTTP transport. Now all responses are returned via http. Events still uses JS callbacks, as HTTP doesn't support bidirectional connect.
- Replace GET
/wails/runtimewith POST/wails/runtimeto handle cases with large data (#4428) - Moved
/wails/capabilitiesand/wails/flagsunder messageProcessor for object System to allow other transports handle those requests as well - Inject all flags that were specified for the app in webview (previously only
resizeHandleWidthandresizeHandleHeightfor Windows were passed) - Decouple logic of bindings transport from message processor.
- Introduce Transport interfaces, that allow to replace default HTTP transport for bindings handling
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue) https://github.com/wailsapp/wails/issues/4418 https://github.com/wailsapp/wails/issues/4428 https://github.com/wailsapp/wails/issues/1516 https://github.com/wailsapp/wails/issues/4686
Type of change
Please select the option that is relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.
- [ ] Windows
- [x] macOS
- [ ] Linux
If you checked Linux, please specify the distro and version.
Test Configuration
Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.
Wails (v3.0.0-dev) Wails Doctor
# System
┌──────────────────────────────────────────────────┐
| Name | MacOS |
| Version | 26.0.1 |
| ID | 25A362 |
| Branding | MacOS 26.0.1 |
| Platform | darwin |
| Architecture | arm64 |
| Apple Silicon | true |
| CPU | Apple M4 Max |
| CPU 1 | Apple M4 Max |
| CPU 2 | Apple M4 Max |
| GPU | 40 cores, Metal Support: Metal 4 |
| Memory | 128 GB |
└──────────────────────────────────────────────────┘
# Build Environment
┌─────────────────────────────────────────────────────────┐
| Wails CLI | v3.0.0-dev |
| Go Version | go1.24.0 |
| Revision | 4a445ce218b58db4a16ee8fa84eac0d7c9a69932 |
| Modified | false |
| -buildmode | exe |
| -compiler | gc |
| CGO_CFLAGS | |
| CGO_CPPFLAGS | |
| CGO_CXXFLAGS | |
| CGO_ENABLED | 1 |
| CGO_LDFLAGS | |
| GOARCH | arm64 |
| GOARM64 | v8.0 |
| GOOS | darwin |
| vcs | git |
| vcs.modified | false |
| vcs.revision | 4a445ce218b58db4a16ee8fa84eac0d7c9a69932 |
| vcs.time | 2025-08-04T22:42:25Z |
└─────────────────────────────────────────────────────────┘
Checklist:
- [ ] I have updated
website/src/pages/changelog.mdxwith details of this PR - [x] My code follows the general coding style of this project
- x ] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
Summary by CodeRabbit
-
New Features
- Added support for custom transport layer implementations, enabling alternative IPC protocols like WebSocket.
- Introduced WebSocket transport example with backend and frontend integration.
- Added structured error handling framework for improved debugging.
-
Refactor
- Refactored internal runtime message processing to support pluggable transport backends.
- Redesigned IPC transport architecture for better extensibility.
✏️ Tip: You can customize this high-level summary in your review settings.