-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from owncloud/initial-phoenix
Embed phoenix and serve it
- Loading branch information
Showing
26 changed files
with
2,094 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ coverage.out | |
|
||
/bin | ||
/dist | ||
|
||
/phoenix |
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
--- | ||
server: | ||
debug: | ||
addr: 0.0.0.0:8090 | ||
token: | ||
pprof: false | ||
|
||
http: | ||
addr: 0.0.0.0:8080 | ||
root: / | ||
|
||
metrics: | ||
addr: 0.0.0.0:8090 | ||
asset: | ||
path: | ||
|
||
config: | ||
file: | ||
|
||
... |
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,59 @@ | ||
package assets | ||
|
||
import ( | ||
"net/http" | ||
"os" | ||
"path" | ||
|
||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
//go:generate go run github.com/UnnoTed/fileb0x embed.yml | ||
|
||
// assets gets initialized by New and provides the handler. | ||
type assets struct { | ||
path string | ||
} | ||
|
||
// Open just implements the HTTP filesystem interface. | ||
func (a assets) Open(original string) (http.File, error) { | ||
if a.path != "" { | ||
if stat, err := os.Stat(a.path); err == nil && stat.IsDir() { | ||
custom := path.Join( | ||
a.path, | ||
original, | ||
) | ||
|
||
if _, err := os.Stat(custom); !os.IsNotExist(err) { | ||
f, err := os.Open(custom) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return f, nil | ||
} | ||
} else { | ||
log.Warn(). | ||
Msg("Assets directory doesn't exist") | ||
} | ||
} | ||
|
||
return FS.OpenFile( | ||
CTX, | ||
original, | ||
os.O_RDONLY, | ||
0644, | ||
) | ||
} | ||
|
||
// New returns a new http filesystem to serve assets. | ||
func New(opts ...Option) http.FileSystem { | ||
a := new(assets) | ||
|
||
for _, opt := range opts { | ||
opt(a) | ||
} | ||
|
||
return a | ||
} |
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,9 @@ | ||
package assets | ||
|
||
import ( | ||
// Fake the import to make the dep tree happy. | ||
_ "golang.org/x/net/context" | ||
|
||
// Fake the import to make the dep tree happy. | ||
_ "golang.org/x/net/webdav" | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
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,23 @@ | ||
--- | ||
pkg: "assets" | ||
dest: "." | ||
output: "embed.go" | ||
fmt: true | ||
noprefix: true | ||
|
||
compression: | ||
compress: true | ||
|
||
custom: | ||
- files: | ||
- "../../phoenix/" | ||
base: "../../phoenix/" | ||
prefix: "" | ||
exclude: | ||
- "appinfo/**" | ||
- "LICENSE/**" | ||
- "CHANGELOG.md" | ||
- "README.md" | ||
- "config.json" | ||
|
||
... |
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,11 @@ | ||
package assets | ||
|
||
// Option configures an assets option. | ||
type Option func(*assets) | ||
|
||
// WithPath returns an option to set custom assets path. | ||
func WithPath(val string) Option { | ||
return func(a *assets) { | ||
a.path = val | ||
} | ||
} |
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,18 @@ | ||
package command | ||
|
||
import ( | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// init defined the default options for viper. | ||
func init() { | ||
viper.SetDefault("debug.addr", "0.0.0.0:8090") | ||
viper.SetDefault("debug.token", "") | ||
viper.SetDefault("debug.pprof", false) | ||
|
||
viper.SetDefault("http.addr", "0.0.0.0:8080") | ||
viper.SetDefault("http.root", "/") | ||
|
||
viper.SetDefault("asset.path", "") | ||
viper.SetDefault("config.file", "") | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.