Created
May 17, 2015 13:44
-
-
Save Bondifrench/5734aded952ccccfc131 to your computer and use it in GitHub Desktop.
Mithril example with control access for specific route - from Barney Carroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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