Interface definition

An interace in MIDL describes a set of endpoints.

For example, this is an MIDL file that defines two endpoints:

// This file is at src/haxe/userSdk/rpc/Rpc.hx
package userSdk.rpc;

// Import Future, which holds asynchronous operations.
import jsonStream.rpc.Future;

// Import Profile, which should be defined in src/haxe/userSdk/model/Models.hx
import userSdk.model.Models.Profile;

interface IUserProfileService {

  @:route("GET", "users/{userId}")
  function getProfile(userId:String):Future<Profile>;

  @:requestHeader("Your-Custom-Header", "custom-header-value")
  @:route("PUT", "users/{userId}")
  function setProfile(userId:String, profile:Profile):Future<Void>;


interface IMyOtherService {
  // Put other endpoint definitions here...

Package and directory layout

MIDL uses Haxe's package and import syntax to locate MIDL files. The file must be at the path corresponds to current package. For example, if you configured source path at src/haxe and set package is userSdk.rpc, then the file must be under src/haxe/userSdk/rpc/ directory.

Unlike Java, Haxe's source file may contains multiple root types, and the file name does not have to be the same as the type name. So you could name the MIDL file as Rpc.hx and put IUserProfileService and IMyOtherService interface in it.

Interfaces and methods

MIDL uses Haxe's interface and method syntax to define endpoints. Then, Microbuilder compiler can generate the implementation of these methods into client-side SDKs. Applications could call these methods in SDK to send HTTP requests.

See Annotations for more information about mapping between RESTful JSON API and methods.