1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

version 12.1.5

Former-commit-id: cda69f08955cb0d594e98bf26197ee573cbba4b2
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-02-02 16:29:06 +02:00
parent e04ea83c04
commit 3093d65363
76 changed files with 9647 additions and 366 deletions

View File

@@ -4,5 +4,5 @@ go 1.13
require (
github.com/betacraft/yaag v1.0.1-0.20191027021412-565f65e36090
github.com/kataras/iris/v12 v12.1.4
github.com/kataras/iris/v12 v12.1.5
)

View File

@@ -0,0 +1 @@
just a text.

View File

@@ -0,0 +1 @@
<h1>Hello App2App3 index</h1>

View File

@@ -0,0 +1 @@
<h1>Hello App2 index</h1>

View File

@@ -0,0 +1,3 @@
body {
background-color: black;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1 @@
<h1>Hello index</h1>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
127.0.0.1 examle.com
127.0.0.1 v1.examle.com

View File

@@ -0,0 +1,29 @@
package main
import (
"github.com/kataras/iris/v12"
)
const (
addr = "example.com:80"
subdomain = "v1"
)
func newApp() *iris.Application {
app := iris.New()
app.Favicon("./assets/favicon.ico")
v1 := app.Subdomain(subdomain)
v1.HandleDir("/", "./assets", iris.DirOptions{})
// http://v1.example.com
// http://v1.example.com/css/main.css
// http://v1.example.com/js/jquery-2.1.1.js
// http://v1.example.com/favicon.ico
return app
}
func main() {
app := newApp()
app.Run(iris.Addr(addr))
}

View File

@@ -0,0 +1,81 @@
package main
import (
"io/ioutil"
"net"
"path/filepath"
"testing"
"github.com/kataras/iris/v12/httptest"
)
type resource string
func (r resource) contentType() string {
switch filepath.Ext(r.String()) {
case ".js":
return "application/javascript"
case ".css":
return "text/css"
case ".ico":
return "image/x-icon"
case ".html", "":
return "text/html"
default:
return "text/plain"
}
}
func (r resource) String() string {
return string(r)
}
func (r resource) loadFromBase(dir string) string {
filename := r.String()
if filepath.Ext(filename) == "" {
// root /.
filename = filename + "/index.html"
}
fullpath := filepath.Join(dir, filename)
b, err := ioutil.ReadFile(fullpath)
if err != nil {
panic(fullpath + " failed with error: " + err.Error())
}
result := string(b)
return result
}
func TestFileServerSubdomainBasic(t *testing.T) {
urls := []resource{
"/css/main.css",
"/js/jquery-2.1.1.js",
"/favicon.ico",
"/app2",
"/app2/app2app3",
"/",
}
app := newApp()
e := httptest.New(t, app)
host, _, err := net.SplitHostPort(addr)
if err != nil {
t.Fatal(err)
}
host = "http://" + subdomain + "." + host
for _, u := range urls {
url := u.String()
contents := u.loadFromBase("./assets")
e.GET(url).WithURL(host).Expect().
Status(httptest.StatusOK).
ContentType(u.contentType(), app.ConfigurationReadOnly().GetCharset()).
Body().Equal(contents)
}
}

View File

@@ -4,5 +4,5 @@ go 1.13
require (
github.com/googollee/go-socket.io v1.4.3-0.20191109153049-7451e2f8c2e0 // indirect
github.com/kataras/iris/v12 v12.1.4
github.com/kataras/iris/v12 v12.1.5
)