Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkozhukh/go-remote
client/server transport for js/go
https://github.com/mkozhukh/go-remote
Last synced: 30 days ago
JSON representation
client/server transport for js/go
- Host: GitHub
- URL: https://github.com/mkozhukh/go-remote
- Owner: mkozhukh
- Created: 2018-01-24T20:24:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-27T13:13:52.000Z (over 1 year ago)
- Last Synced: 2024-04-30T09:02:04.702Z (8 months ago)
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Remote - client/server transport for js/go
======================## Server side
```go
s := remote.NewServer()
guard := func(req *http.Request) bool {
return login.CheckAccess(req, auth.AdminAccess)
}s.Register("snippet", &SnippetAPI{})
s.RegisterWithGuard("admin", &SnippetAdminAPI{}, guard)
s.RegisterConstant("versions", "1.0")s.RegisterProvider(func(r *http.Request) *User {
return User{}
})
s.RegisterVariable("user", &User{})router.Handle("/api/v1", s)
```## Client side
```html
alert(remote.data.version);
remote.api.snippet.Save(config);remote.onload = function(promise){
//called each time when server side communcation started
};remote.onerror = function(err){
//called each time when server side error occurs
};```