Skip to content

Fork this repo and link it to your StackMob account to get started with auto-deploying your Custom Code.

License

Notifications You must be signed in to change notification settings

seans23/stackmob-customcode-maven

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StackMob Custom Code Example Project (Maven-based)

This example project is a simple Hello World. This adds a server-side method called "hello_world" which can be called from your client iOS, Android, Java Client or JS SDKs:

http://api.stackmob.com/hello_world

Custom code allows you to even define the returned JSON. In this case, our simple Hello World example will return:

{ "msg": "Hello, world!" }

You can call your server-side custom code from your SDK. The request will be sent from the client, StackMob will route the call to the appropriate code and execute the code you've written, then StackMob will return the JSON you've defined.

**iOS SDK**
[[StackMob stackmob] get:@"hello_world" withCallback:^(BOOL success, id result) {
    if (success) {
        // result is the JSON as an NSDictionary of "msg" vs. "Hello, world!"
    } else {
    }
}];
**Android SDK**
StackMobCommon.getStackMobInstance().get("hello_world", new StackMobCallback() {
    @Override public void success(String responseBody) {
        //responseBody is "{ \"msg\": \"Hello, world!\" }"
    }
    @Override public void failure(StackMobException e) {
    }
});
**JS SDK**
<script type="text/javascript">
  StackMob.customcode('hello_world', {}, {
     success: function(jsonResult) {
       //jsonResult is the JSON object: { "msg": "Hello, world!" }
     },
     
     error: function(failure) {
       //doh!
     }
  });
</script>

Java (Maven)

Building:

  1. mvn clean package
  2. JAR is located in target

Deploying

To deploy your Custom Code, first link your github repo with StackMob by authorizing StackMob here. Then follow the provided instructions to configure the deploy hook on GitHub. After that just 'push' to your 'master' branch and your code will be built and deployed seamlessly to the StackMob platform. Your code is only automatically deployed in the Development environment. You retain control when you want to manually deploy to Production. You can also see a history of your deployments.

About

Fork this repo and link it to your StackMob account to get started with auto-deploying your Custom Code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 100.0%