mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 05:42:09 -05:00
parent
50c819cede
commit
83e46555dd
1 changed files with 22 additions and 1 deletions
|
@ -49,6 +49,26 @@ serve them up.`,
|
||||||
//Run: server,
|
//Run: server,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type filesOnlyFs struct {
|
||||||
|
fs http.FileSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
type noDirFile struct {
|
||||||
|
http.File
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fs filesOnlyFs) Open(name string) (http.File, error) {
|
||||||
|
f, err := fs.fs.Open(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return noDirFile{f}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f noDirFile) Readdir(count int) ([]os.FileInfo, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port on which the server will listen")
|
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port on which the server will listen")
|
||||||
serverCmd.Flags().StringVarP(&serverInterface, "bind", "", "127.0.0.1", "interface to which the server will bind")
|
serverCmd.Flags().StringVarP(&serverInterface, "bind", "", "127.0.0.1", "interface to which the server will bind")
|
||||||
|
@ -125,7 +145,8 @@ func serve(port int) {
|
||||||
jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("PublishDir")))
|
jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("PublishDir")))
|
||||||
|
|
||||||
httpFs := &afero.HttpFs{SourceFs: hugofs.DestinationFS}
|
httpFs := &afero.HttpFs{SourceFs: hugofs.DestinationFS}
|
||||||
fileserver := http.FileServer(httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir"))))
|
fs := filesOnlyFs{httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir")))}
|
||||||
|
fileserver := http.FileServer(fs)
|
||||||
|
|
||||||
// We're only interested in the path
|
// We're only interested in the path
|
||||||
u, err := url.Parse(viper.GetString("BaseURL"))
|
u, err := url.Parse(viper.GetString("BaseURL"))
|
||||||
|
|
Loading…
Reference in a new issue