Package com.vtence.molecule.middlewares

Examples of com.vtence.molecule.middlewares.Router


public class DynamicRoutesTest {

    @Test public void
    opensRoutesMatchingSpecifiedPathsAndVerbs() throws Exception {
        Router router = Router.draw(new DynamicRoutes() {{
            map("/uri").via(HttpMethod.POST).to(echo("post to /uri"));
            map("/other/uri").via(HttpMethod.GET).to(echo("get to /other/uri"));
        }}).defaultsTo(echo("not matched"));

        dispatch(router, GET("/other/uri")).assertBody("get to /other/uri");
View Full Code Here


        dispatch(router, POST("/uri")).assertBody("post to /uri");
    }

    @Test public void
    providesConvenientShortcutsForDrawingRoutesUsingStandardVerbs() throws Exception {
        Router router = Router.draw(new DynamicRoutes() {{
            get("/").to(echo("get"));
            put("/").to(echo("put"));
            post("/").to(echo("post"));
            delete("/").to(echo("delete"));
        }}).defaultsTo(echo("not matched"));
View Full Code Here

        dispatch(router, DELETE("/")).assertBody("delete");
    }

    @Test public void
    drawsRoutesInOrder() throws Exception {
        Router router = Router.draw(new DynamicRoutes() {{
            map("/").via(HttpMethod.GET).to(echo("get /"));
            map("/").to(echo("any /"));
        }}).defaultsTo(echo("not matched"));

        dispatch(router, GET("/"));
View Full Code Here

TOP

Related Classes of com.vtence.molecule.middlewares.Router

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.