Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
};

```