https://github.com/cheikhshift/momentum
GopherSauce.com RPC auto-gen 📦 . Etymology of name : Angular + momentum [DEPRECATED]
https://github.com/cheikhshift/momentum
rpc-framework rpc-service
Last synced: 6 months ago
JSON representation
GopherSauce.com RPC auto-gen 📦 . Etymology of name : Angular + momentum [DEPRECATED]
- Host: GitHub
- URL: https://github.com/cheikhshift/momentum
- Owner: cheikhshift
- License: bsd-3-clause
- Created: 2017-11-15T16:28:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-03T12:23:28.000Z (over 7 years ago)
- Last Synced: 2025-10-05T22:39:59.463Z (9 months ago)
- Topics: rpc-framework, rpc-service
- Language: Go
- Homepage: http://gophersauce.com
- Size: 58.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# [DEPRECATED]
Incompatible with Gopher Sauce +v0.6.0
### Momentum
A GopherSauce package to convert template and func tags into accessible Javascript functions. The goal of this project is to be able to: 1) generate your templates on your server 2) Ease access to server side functionality.
## Without GopherSauce
Download the CLI to build RPC functions without GopherSauce. Find it [here](https://github.com/cheikhshift/momentum/tree/master/cmd/momentum-cli)
## Requirements
- [GopherSauce](http://gophersauce.com)
## How it works
### Install
Add this import tag to the root of your `gos.gxml` file. Within the `` tag. This will activate momentum within your project. Remember to include the funcfactory within the pages you wish to use these functions. ``
### Templates
Each template created will have a JS function equivalent with the same name. The format of the generated functions are as follows :
function TemplateName(ObjectWithInterfaceFields, function callback(StringOfRenderedTemplate) {} )
Notes : Replace TemplateName with the string specified as the name attribute of your template tag. `ObjectWithInterfaceFields` is a JS object that will be converted to the interface specified within your template tag's `struct` attribute. On error, the reason why will be returned instead of the template HTML.
### Funcs
Each `func` tag within your `` section will generate a JS equivalent function. To better visualize this follow the example below.
Notes : Channels are not supported as a valid type within `var` and `return` attributes of your func tag. Using the term `args ...interface` will not work as well. This is why the `` tag was introduced, to provide users with a tag to explicitly declare variable types. With this in mind `` tags will not work with JS function factory because it relies `args ..interface` to pass variables.
A sample `` tag is declared within the methods section of a `gos.gxml` file. The return type specifies names returned values.
err = errors.New("error test on GOOOO")
test = "Test" + varx
return
The previous func tag will generate JS function : (The variable definitions carry over to javascript.)
function TestAdd(Varx,Numv, function callback(ObjectResponse, success) )
Notes : ObjectResponse variable is an object with your function's returned values. With this `` tag, the ObjectResponse will have keys `err` and `test` following the tag's return attribute. Success is an indication of successful method invocation. On error, Object response will have one key : `error`, which is a string explanation of why the request failed.
**More notes : You must specify the names of the return types as well, AKA `Named returned values`. These names will be used as key names to your response oject.
*** Angular notes : If you plan on using Angular JS, use this $scope function to update your data after setting it within your callback `$scope.$apply();`.
#### Api format
You can access each of your functions via server URI `/momentum/funcs`.
##### Get Parameters
- name : specifies the name of the function to invoke.
##### Post Body
The body is used to pass a json of your function's variables/parameters. Each json key should match a correponding function variable name, with that variable's data specified as the key's value.