mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 10:56:29 +01:00
fix embedded fs not access to dir list because of options.ShowList unnecessary check. Solves #1383
Former-commit-id: 1ad4535deb1c4792408a3bf63456b333aa752594
This commit is contained in:
parent
221978e41a
commit
0e2c44e231
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
go get github.com/betacraft/yaag/...
|
go get github.com/betacraft/yaag@v1.0.1-0.20190930134538-3ebbf33677d5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type myXML struct {
|
type myXML struct {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// Code generated by go-bindata.
|
// Code generated by go-bindata. DO NOT EDIT.
|
||||||
// sources:
|
// sources:
|
||||||
// public/app.js
|
// public\app.js
|
||||||
// public/css/main.css
|
// public\app2\index.html
|
||||||
// public/index.html
|
// public\css\main.css
|
||||||
// DO NOT EDIT!
|
// public\index.html
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -41,14 +41,20 @@ func bindataRead(data []byte, name string) ([]byte, error) {
|
||||||
|
|
||||||
type asset struct {
|
type asset struct {
|
||||||
bytes []byte
|
bytes []byte
|
||||||
info os.FileInfo
|
info fileInfoEx
|
||||||
|
}
|
||||||
|
|
||||||
|
type fileInfoEx interface {
|
||||||
|
os.FileInfo
|
||||||
|
MD5Checksum() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type bindataFileInfo struct {
|
type bindataFileInfo struct {
|
||||||
name string
|
name string
|
||||||
size int64
|
size int64
|
||||||
mode os.FileMode
|
mode os.FileMode
|
||||||
modTime time.Time
|
modTime time.Time
|
||||||
|
md5checksum string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fi bindataFileInfo) Name() string {
|
func (fi bindataFileInfo) Name() string {
|
||||||
|
@ -63,6 +69,9 @@ func (fi bindataFileInfo) Mode() os.FileMode {
|
||||||
func (fi bindataFileInfo) ModTime() time.Time {
|
func (fi bindataFileInfo) ModTime() time.Time {
|
||||||
return fi.modTime
|
return fi.modTime
|
||||||
}
|
}
|
||||||
|
func (fi bindataFileInfo) MD5Checksum() string {
|
||||||
|
return fi.md5checksum
|
||||||
|
}
|
||||||
func (fi bindataFileInfo) IsDir() bool {
|
func (fi bindataFileInfo) IsDir() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -70,69 +79,140 @@ func (fi bindataFileInfo) Sys() interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _publicAppJs = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\xcf\xcc\x4b\xc9\x2f\xd7\x4b\xcc\x49\x2d\x2a\xd1\x50\x4a\x2c\x28\xd0\xcb\x2a\x56\xc8\xc9\x4f\x4c\x49\x4d\x51\x48\x2b\xca\xcf\x55\x88\x51\xd2\x57\xd2\xb4\x06\x04\x00\x00\xff\xff\xa9\x06\xf7\xa3\x27\x00\x00\x00")
|
var _bindataPublicappjs = []byte(
|
||||||
|
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\xcf\xcc\x4b\xc9\x2f\xd7\x4b\xcc\x49\x2d\x2a\xd1\x50\x4a\x2c\x28\xd0" +
|
||||||
|
"\xcb\x2a\x56\xc8\xc9\x4f\x4c\x49\x4d\x51\x48\x2b\xca\xcf\x55\x88\x51\xd2\x57\xd2\xb4\x06\x04\x00\x00\xff\xff\xa9" +
|
||||||
|
"\x06\xf7\xa3\x27\x00\x00\x00")
|
||||||
|
|
||||||
func publicAppJsBytes() ([]byte, error) {
|
func bindataPublicappjsBytes() ([]byte, error) {
|
||||||
return bindataRead(
|
return bindataRead(
|
||||||
_publicAppJs,
|
_bindataPublicappjs,
|
||||||
"public/app.js",
|
"public/app.js",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func publicAppJs() (*asset, error) {
|
func bindataPublicappjs() (*asset, error) {
|
||||||
bytes, err := publicAppJsBytes()
|
bytes, err := bindataPublicappjsBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/app.js", size: 39, mode: os.FileMode(438), modTime: time.Unix(1497458456, 0)}
|
info := bindataFileInfo{
|
||||||
|
name: "public/app.js",
|
||||||
|
size: 39,
|
||||||
|
md5checksum: "",
|
||||||
|
mode: os.FileMode(438),
|
||||||
|
modTime: time.Unix(1565946441, 0),
|
||||||
|
}
|
||||||
|
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
|
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _publicCssMainCss = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4a\xca\x4f\xa9\x54\xa8\xe6\xe5\x52\x50\x50\x50\x48\x4a\x4c\xce\x4e\x2f\xca\x2f\xcd\x4b\xd1\x4d\xce\xcf\xc9\x2f\xb2\x52\x48\xca\x49\x4c\xce\xb6\xe6\xe5\xaa\xe5\xe5\x02\x04\x00\x00\xff\xff\x03\x25\x9c\x89\x29\x00\x00\x00")
|
var _bindataPublicapp2indexhtml = []byte(
|
||||||
|
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\x8d\x41\x0a\xc2\x40\x0c\x45\xf7\x81\xdc\xe1\x9f\xc0\xd0\xae\x43\xc0" +
|
||||||
|
"\x9d\xd7\xa8\x4c\x24\x85\xd4\x09\x32\x0b\xbd\xbd\xb4\xd6\xe5\x87\xf7\xde\xd7\x18\x5b\x1a\x13\x93\x86\x2f\xcd\x98" +
|
||||||
|
"\x00\x40\xc7\x3a\xd2\xed\x5a\x85\x59\xe5\x37\x98\x54\x4e\x84\x49\xef\xbd\x7d\xfe\x70\x4c\x86\x9b\x67\x76\x3c\x5e" +
|
||||||
|
"\x7d\xc3\x52\x35\xcb\xfa\x6c\xfe\xbe\xec\x71\xa8\xc4\x74\xd8\xa7\x73\x84\xf6\xd7\x6f\x00\x00\x00\xff\xff\xfd\x28" +
|
||||||
|
"\x92\x95\x7c\x00\x00\x00")
|
||||||
|
|
||||||
func publicCssMainCssBytes() ([]byte, error) {
|
func bindataPublicapp2indexhtmlBytes() ([]byte, error) {
|
||||||
return bindataRead(
|
return bindataRead(
|
||||||
_publicCssMainCss,
|
_bindataPublicapp2indexhtml,
|
||||||
|
"public/app2/index.html",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bindataPublicapp2indexhtml() (*asset, error) {
|
||||||
|
bytes, err := bindataPublicapp2indexhtmlBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := bindataFileInfo{
|
||||||
|
name: "public/app2/index.html",
|
||||||
|
size: 124,
|
||||||
|
md5checksum: "",
|
||||||
|
mode: os.FileMode(438),
|
||||||
|
modTime: time.Unix(1571953700, 0),
|
||||||
|
}
|
||||||
|
|
||||||
|
a := &asset{bytes: bytes, info: info}
|
||||||
|
|
||||||
|
return a, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var _bindataPubliccssmaincss = []byte(
|
||||||
|
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4a\xca\x4f\xa9\x54\xa8\xe6\xe5\x52\x50\x50\x50\x48\x4a\x4c\xce\x4e\x2f" +
|
||||||
|
"\xca\x2f\xcd\x4b\xd1\x4d\xce\xcf\xc9\x2f\xb2\x52\x48\xca\x49\x4c\xce\xb6\xe6\xe5\xaa\xe5\xe5\x02\x04\x00\x00\xff" +
|
||||||
|
"\xff\x03\x25\x9c\x89\x29\x00\x00\x00")
|
||||||
|
|
||||||
|
func bindataPubliccssmaincssBytes() ([]byte, error) {
|
||||||
|
return bindataRead(
|
||||||
|
_bindataPubliccssmaincss,
|
||||||
"public/css/main.css",
|
"public/css/main.css",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func publicCssMainCss() (*asset, error) {
|
func bindataPubliccssmaincss() (*asset, error) {
|
||||||
bytes, err := publicCssMainCssBytes()
|
bytes, err := bindataPubliccssmaincssBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/css/main.css", size: 41, mode: os.FileMode(438), modTime: time.Unix(1497455997, 0)}
|
info := bindataFileInfo{
|
||||||
|
name: "public/css/main.css",
|
||||||
|
size: 41,
|
||||||
|
md5checksum: "",
|
||||||
|
mode: os.FileMode(438),
|
||||||
|
modTime: time.Unix(1565946441, 0),
|
||||||
|
}
|
||||||
|
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
|
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _publicIndexHtml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\x8e\x41\x0e\xc2\x20\x10\x45\xf7\x24\xdc\xe1\xa7\x07\x80\x74\x3f\xb2\x76\xe9\xc2\x0b\x60\x41\xc1\x50\x21\xc0\x42\xd3\xf4\xee\x06\x4a\x97\x93\xf7\x66\xde\x90\xab\x6b\x50\x9c\x71\x46\xce\x6a\xa3\x38\x03\x00\xaa\xbe\x06\xab\xb6\x0d\xe2\xa6\x5f\x56\xdc\xdb\x88\x7d\x27\x79\x00\xce\x48\x0e\x9d\x33\x7a\x44\xf3\x3b\x17\xdd\xac\x70\xb5\x21\x44\x3c\x73\x5c\xe1\x3f\xc6\x7e\x45\x6b\x80\xa4\x9b\xbb\x3f\xcc\xb2\x64\x9f\x2a\x4a\x5e\x2e\x93\xd4\x29\x89\x77\x99\x14\x40\xf2\x00\xbd\x31\x2e\xf7\x5c\xfb\xf3\x1f\x00\x00\xff\xff\x25\xe9\x37\x57\xae\x00\x00\x00")
|
var _bindataPublicindexhtml = []byte(
|
||||||
|
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\x8e\x41\x0e\xc2\x20\x10\x45\xf7\x24\xdc\xe1\xa7\x07\x80\x74\x3f\xb2" +
|
||||||
|
"\x76\xe9\xc2\x0b\x60\x41\xc1\x50\x21\xc0\x42\xd3\xf4\xee\x06\x4a\x97\x93\xf7\x66\xde\x90\xab\x6b\x50\x9c\x71\x46" +
|
||||||
|
"\xce\x6a\xa3\x38\x03\x00\xaa\xbe\x06\xab\xb6\x0d\xe2\xa6\x5f\x56\xdc\xdb\x88\x7d\x27\x79\x00\xce\x48\x0e\x9d\x33" +
|
||||||
|
"\x7a\x44\xf3\x3b\x17\xdd\xac\x70\xb5\x21\x44\x3c\x73\x5c\xe1\x3f\xc6\x7e\x45\x6b\x80\xa4\x9b\xbb\x3f\xcc\xb2\x64" +
|
||||||
|
"\x9f\x2a\x4a\x5e\x2e\x93\xd4\x29\x89\x77\x99\x14\x40\xf2\x00\xbd\x31\x2e\xf7\x5c\xfb\xf3\x1f\x00\x00\xff\xff\x25" +
|
||||||
|
"\xe9\x37\x57\xae\x00\x00\x00")
|
||||||
|
|
||||||
func publicIndexHtmlBytes() ([]byte, error) {
|
func bindataPublicindexhtmlBytes() ([]byte, error) {
|
||||||
return bindataRead(
|
return bindataRead(
|
||||||
_publicIndexHtml,
|
_bindataPublicindexhtml,
|
||||||
"public/index.html",
|
"public/index.html",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func publicIndexHtml() (*asset, error) {
|
func bindataPublicindexhtml() (*asset, error) {
|
||||||
bytes, err := publicIndexHtmlBytes()
|
bytes, err := bindataPublicindexhtmlBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/index.html", size: 174, mode: os.FileMode(438), modTime: time.Unix(1497460815, 0)}
|
info := bindataFileInfo{
|
||||||
|
name: "public/index.html",
|
||||||
|
size: 174,
|
||||||
|
md5checksum: "",
|
||||||
|
mode: os.FileMode(438),
|
||||||
|
modTime: time.Unix(1565946441, 0),
|
||||||
|
}
|
||||||
|
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
|
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// Asset loads and returns the asset for the given name.
|
// Asset loads and returns the asset for the given name.
|
||||||
// It returns an error if the asset could not be found or
|
// It returns an error if the asset could not be found or
|
||||||
// could not be loaded.
|
// could not be loaded.
|
||||||
|
//
|
||||||
func Asset(name string) ([]byte, error) {
|
func Asset(name string) ([]byte, error) {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
if f, ok := _bindata[cannonicalName]; ok {
|
if f, ok := _bindata[cannonicalName]; ok {
|
||||||
|
@ -142,11 +222,14 @@ func Asset(name string) ([]byte, error) {
|
||||||
}
|
}
|
||||||
return a.bytes, nil
|
return a.bytes, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("Asset %s not found", name)
|
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// MustAsset is like Asset but panics when Asset would return an error.
|
// MustAsset is like Asset but panics when Asset would return an error.
|
||||||
// It simplifies safe initialization of global variables.
|
// It simplifies safe initialization of global variables.
|
||||||
|
// nolint: deadcode
|
||||||
|
//
|
||||||
func MustAsset(name string) []byte {
|
func MustAsset(name string) []byte {
|
||||||
a, err := Asset(name)
|
a, err := Asset(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -156,9 +239,10 @@ func MustAsset(name string) []byte {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// AssetInfo loads and returns the asset info for the given name.
|
// AssetInfo loads and returns the asset info for the given name.
|
||||||
// It returns an error if the asset could not be found or
|
// It returns an error if the asset could not be found or could not be loaded.
|
||||||
// could not be loaded.
|
//
|
||||||
func AssetInfo(name string) (os.FileInfo, error) {
|
func AssetInfo(name string) (os.FileInfo, error) {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
if f, ok := _bindata[cannonicalName]; ok {
|
if f, ok := _bindata[cannonicalName]; ok {
|
||||||
|
@ -168,10 +252,13 @@ func AssetInfo(name string) (os.FileInfo, error) {
|
||||||
}
|
}
|
||||||
return a.info, nil
|
return a.info, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("AssetInfo %s not found", name)
|
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// AssetNames returns the names of the assets.
|
// AssetNames returns the names of the assets.
|
||||||
|
// nolint: deadcode
|
||||||
|
//
|
||||||
func AssetNames() []string {
|
func AssetNames() []string {
|
||||||
names := make([]string, 0, len(_bindata))
|
names := make([]string, 0, len(_bindata))
|
||||||
for name := range _bindata {
|
for name := range _bindata {
|
||||||
|
@ -180,13 +267,17 @@ func AssetNames() []string {
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||||
|
//
|
||||||
var _bindata = map[string]func() (*asset, error){
|
var _bindata = map[string]func() (*asset, error){
|
||||||
"public/app.js": publicAppJs,
|
"public/app.js": bindataPublicappjs,
|
||||||
"public/css/main.css": publicCssMainCss,
|
"public/app2/index.html": bindataPublicapp2indexhtml,
|
||||||
"public/index.html": publicIndexHtml,
|
"public/css/main.css": bindataPubliccssmaincss,
|
||||||
|
"public/index.html": bindataPublicindexhtml,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// AssetDir returns the file names below a certain
|
// AssetDir returns the file names below a certain
|
||||||
// directory embedded in the file by go-bindata.
|
// directory embedded in the file by go-bindata.
|
||||||
// For example if you run go-bindata on data/... and data contains the
|
// For example if you run go-bindata on data/... and data contains the
|
||||||
|
@ -200,6 +291,7 @@ var _bindata = map[string]func() (*asset, error){
|
||||||
// AssetDir("data/img") would return []string{"a.png", "b.png"}
|
// AssetDir("data/img") would return []string{"a.png", "b.png"}
|
||||||
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
|
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
|
||||||
// AssetDir("") will return []string{"data"}.
|
// AssetDir("") will return []string{"data"}.
|
||||||
|
//
|
||||||
func AssetDir(name string) ([]string, error) {
|
func AssetDir(name string) ([]string, error) {
|
||||||
node := _bintree
|
node := _bintree
|
||||||
if len(name) != 0 {
|
if len(name) != 0 {
|
||||||
|
@ -208,12 +300,20 @@ func AssetDir(name string) ([]string, error) {
|
||||||
for _, p := range pathList {
|
for _, p := range pathList {
|
||||||
node = node.Children[p]
|
node = node.Children[p]
|
||||||
if node == nil {
|
if node == nil {
|
||||||
return nil, fmt.Errorf("Asset %s not found", name)
|
return nil, &os.PathError{
|
||||||
|
Op: "open",
|
||||||
|
Path: name,
|
||||||
|
Err: os.ErrNotExist,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if node.Func != nil {
|
if node.Func != nil {
|
||||||
return nil, fmt.Errorf("Asset %s not found", name)
|
return nil, &os.PathError{
|
||||||
|
Op: "open",
|
||||||
|
Path: name,
|
||||||
|
Err: os.ErrNotExist,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rv := make([]string, 0, len(node.Children))
|
rv := make([]string, 0, len(node.Children))
|
||||||
for childName := range node.Children {
|
for childName := range node.Children {
|
||||||
|
@ -227,13 +327,16 @@ type bintree struct {
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
|
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{Func: nil, Children: map[string]*bintree{
|
||||||
"public": {nil, map[string]*bintree{
|
"public": {Func: nil, Children: map[string]*bintree{
|
||||||
"app.js": {publicAppJs, map[string]*bintree{}},
|
"app.js": {Func: bindataPublicappjs, Children: map[string]*bintree{}},
|
||||||
"css": {nil, map[string]*bintree{
|
"app2": {Func: nil, Children: map[string]*bintree{
|
||||||
"main.css": {publicCssMainCss, map[string]*bintree{}},
|
"index.html": {Func: bindataPublicapp2indexhtml, Children: map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
"index.html": {publicIndexHtml, map[string]*bintree{}},
|
"css": {Func: nil, Children: map[string]*bintree{
|
||||||
|
"main.css": {Func: bindataPubliccssmaincss, Children: map[string]*bintree{}},
|
||||||
|
}},
|
||||||
|
"index.html": {Func: bindataPublicindexhtml, Children: map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -255,11 +358,7 @@ func RestoreAsset(dir, name string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreAssets restores an asset under the given directory recursively
|
// RestoreAssets restores an asset under the given directory recursively
|
||||||
|
|
|
@ -6,8 +6,7 @@ import (
|
||||||
|
|
||||||
// $ go get -u github.com/shuLhan/go-bindata/...
|
// $ go get -u github.com/shuLhan/go-bindata/...
|
||||||
// $ go-bindata ./public/...
|
// $ go-bindata ./public/...
|
||||||
// $ go build
|
// $ go run .
|
||||||
// $ ./embedded-single-page-application
|
|
||||||
|
|
||||||
var page = struct {
|
var page = struct {
|
||||||
Title string
|
Title string
|
||||||
|
@ -35,8 +34,8 @@ func main() {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
|
||||||
// http://localhost:8080
|
// http://localhost:8080
|
||||||
// http://localhost:8080/index.html
|
|
||||||
// http://localhost:8080/app.js
|
// http://localhost:8080/app.js
|
||||||
// http://localhost:8080/css/main.css
|
// http://localhost:8080/css/main.css
|
||||||
|
// http://localhost:8080/app2
|
||||||
app.Run(iris.Addr(":8080"))
|
app.Run(iris.Addr(":8080"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ func (r resource) strip(strip string) string {
|
||||||
func (r resource) loadFromBase(dir string) string {
|
func (r resource) loadFromBase(dir string) string {
|
||||||
filename := r.String()
|
filename := r.String()
|
||||||
|
|
||||||
if filename == "/" {
|
if strings.HasSuffix(filename, "/") {
|
||||||
filename = "/index.html"
|
filename = filename + "index.html"
|
||||||
}
|
}
|
||||||
|
|
||||||
fullpath := filepath.Join(dir, filename)
|
fullpath := filepath.Join(dir, filename)
|
||||||
|
@ -57,6 +57,8 @@ var urls = []resource{
|
||||||
"/index.html",
|
"/index.html",
|
||||||
"/app.js",
|
"/app.js",
|
||||||
"/css/main.css",
|
"/css/main.css",
|
||||||
|
"/app2/",
|
||||||
|
"/app2/index.html",
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSPAEmbedded(t *testing.T) {
|
func TestSPAEmbedded(t *testing.T) {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>App 2</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1> Hello from app2/index.html </h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -15,7 +15,8 @@ type User struct {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := iris.New()
|
app := iris.New()
|
||||||
// app.Logger().SetLevel("disable") to disable the logger
|
app.Logger().SetLevel("debug")
|
||||||
|
// app.Logger().SetLevel("disable") to disable the logger.
|
||||||
|
|
||||||
// Define templates using the std html/template engine.
|
// Define templates using the std html/template engine.
|
||||||
// Parse and load all files inside "./views" folder with ".html" file extension.
|
// Parse and load all files inside "./views" folder with ".html" file extension.
|
||||||
|
@ -73,6 +74,14 @@ func main() {
|
||||||
usersRoutes.Post("/create", createUser)
|
usersRoutes.Post("/create", createUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.Get("/", func(ctx iris.Context) {
|
||||||
|
ctx.HTML("<html><head></head><body><ul>")
|
||||||
|
for _, link := range []string{"/encode", "/profile/username", "/users/42"} {
|
||||||
|
ctx.HTML(`<li><a href="%s">%s</a></li>`, link, link)
|
||||||
|
}
|
||||||
|
ctx.HTML("</ul></body></html>")
|
||||||
|
})
|
||||||
|
|
||||||
// Listen for incoming HTTP/1.x & HTTP/2 clients on localhost port 8080.
|
// Listen for incoming HTTP/1.x & HTTP/2 clients on localhost port 8080.
|
||||||
app.Run(iris.Addr(":8080"), iris.WithCharset("UTF-8"))
|
app.Run(iris.Addr(":8080"), iris.WithCharset("UTF-8"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,6 @@ var _ http.FileSystem = (*embeddedFileSystem)(nil)
|
||||||
|
|
||||||
func (fs *embeddedFileSystem) Open(name string) (http.File, error) {
|
func (fs *embeddedFileSystem) Open(name string) (http.File, error) {
|
||||||
// name = fs.vdir + name <- no need, check the TrimLeft(name, vdir) on names loop and the asset and assetInfo redefined on `HandleDir`.
|
// name = fs.vdir + name <- no need, check the TrimLeft(name, vdir) on names loop and the asset and assetInfo redefined on `HandleDir`.
|
||||||
|
|
||||||
if d, ok := fs.dirNames[name]; ok {
|
if d, ok := fs.dirNames[name]; ok {
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
@ -239,31 +238,28 @@ func FileServer(directory string, opts ...DirOptions) context.Handler {
|
||||||
|
|
||||||
dirNames := make(map[string]*embeddedDir)
|
dirNames := make(map[string]*embeddedDir)
|
||||||
|
|
||||||
if options.ShowList {
|
// sort filenames by smaller path.
|
||||||
// sort filenames by smaller path.
|
sort.Slice(names, func(i, j int) bool {
|
||||||
sort.Slice(names, func(i, j int) bool {
|
return strings.Count(names[j], "/") > strings.Count(names[i], "/")
|
||||||
return strings.Count(names[j], "/") > strings.Count(names[i], "/")
|
})
|
||||||
})
|
|
||||||
|
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
dirName := path.Dir(name)
|
dirName := path.Dir(name)
|
||||||
d, ok := dirNames[dirName]
|
d, ok := dirNames[dirName]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
d = &embeddedDir{
|
d = &embeddedDir{
|
||||||
name: dirName,
|
name: dirName,
|
||||||
modTimeUnix: time.Now().Unix(),
|
modTimeUnix: time.Now().Unix(),
|
||||||
}
|
|
||||||
dirNames[dirName] = d
|
|
||||||
}
|
}
|
||||||
|
dirNames[dirName] = d
|
||||||
info, err := assetInfo(name)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Sprintf("FileServer: report as bug: file info: %s not found in: %s", name, dirName))
|
|
||||||
}
|
|
||||||
d.list = append(d.list, &embeddedBaseFileInfo{path.Base(name), info})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info, err := assetInfo(name)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("FileServer: report as bug: file info: %s not found in: %s", name, dirName))
|
||||||
|
}
|
||||||
|
d.list = append(d.list, &embeddedBaseFileInfo{path.Base(name), info})
|
||||||
}
|
}
|
||||||
|
|
||||||
fs = &embeddedFileSystem{
|
fs = &embeddedFileSystem{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user