Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add serving spa - the easy way #9 https://github.com/kataras/iris/iss…
- Loading branch information
Showing
5 changed files
with
16,474 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/kataras/iris" | ||
) | ||
|
||
func main() { | ||
|
||
// usersAPI := iris.None("/api/users/:userid", func(ctx *iris.Context) { | ||
// ctx.Writef("user with id: %s", ctx.Param("userid")) | ||
// })("api.users.id") // we need to call empty ("") in order to get its iris.Route instance | ||
// // or ("the name of the route") | ||
// // which later on can be found with iris.Lookup("the name of the route") | ||
|
||
// static := iris.StaticHandler("/", "./www", false, false) | ||
// iris.Get("/*file", iris.Prioritize(usersAPI), static) | ||
// ___OR___ | ||
// static := iris.NewStaticHandlerBuilder("./www").Path("/").Except(usersAPI).Build() | ||
// iris.Get("/*file", static) | ||
|
||
// ___OR___SIMPLY: | ||
|
||
usersAPI := iris.None("/api/users/:userid", func(ctx *iris.Context) { | ||
ctx.Writef("user with id: %s", ctx.Param("userid")) | ||
})("api.users.id") | ||
|
||
iris.StaticWeb("/", "./www", usersAPI) | ||
|
||
// | ||
// START THE SERVER | ||
// | ||
iris.Listen("localhost:8080") | ||
} |
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,12 @@ | ||
<html> | ||
<head> | ||
<title>SPA Index Title</title> | ||
<link rel="stylesheet" href="resources/css/bootstrap.min.css"> | ||
</head> | ||
<body> | ||
<h1>Home</h1> | ||
<button class="btn btn-primary">Hi, Iris</button> | ||
|
||
<script src="resources/js/jquery-2.1.1.js"> </script> | ||
</body> | ||
</html> |
Oops, something went wrong.