-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package examples; | ||
|
||
import express.Express; | ||
import express.ExpressRouter; | ||
|
||
public class Routing { | ||
|
||
public static void main(String[] args) throws Throwable { | ||
Express app = new Express(); | ||
|
||
// Define router for index sites | ||
ExpressRouter indexRouter = new ExpressRouter(); | ||
indexRouter.get("/", (req, res) -> res.send("Hello World!")); | ||
indexRouter.get("/index", (req, res) -> res.send("Index")); | ||
indexRouter.get("/about", (req, res) -> res.send("About")); | ||
|
||
// Define router for user pages | ||
ExpressRouter userRouter = new ExpressRouter(); | ||
userRouter.get("/user/login", (req, res) -> res.send("User Login")); | ||
userRouter.get("/user/register", (req, res) -> res.send("User Register")); | ||
userRouter.get("/user/:username", (req, res) -> res.send("You want to see: " + req.getParam("username"))); | ||
|
||
// Add roter | ||
app.use(indexRouter); | ||
app.use(userRouter); | ||
|
||
// Start server | ||
app.listen(); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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