Skip to content

Instantly share code, notes, and snippets.

@Bondifrench
Created May 17, 2015 13:44
Show Gist options
  • Save Bondifrench/5734aded952ccccfc131 to your computer and use it in GitHub Desktop.
Save Bondifrench/5734aded952ccccfc131 to your computer and use it in GitHub Desktop.
Mithril example with control access for specific route - from Barney Carroll
m.route( document.body, "/dashboard/johndoe", {
"/dashboard/:userID": {
controller : function(){
return m.request( {
url : "/permissions/" + m.route.param( "userID" ),
deserialize : function( xml ){
return new DOMParser().parseFromString( xml, "text/xml" );
}
} ).then(
function success(){},
function failure(){
m.route( "/forbidden" )
}
)
},
view : function( request ){
return m( ".root",
m( "h1", "Welcome, ", m.route.param( "userID" ) )
request()
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment