Skip to content

Commit

Permalink
Merge pull request #27 from xushiwei/app
Browse files Browse the repository at this point in the history
yap with x/http/fsx
  • Loading branch information
xushiwei authored Jan 20, 2024
2 parents 6842bbe + ae7df69 commit ffebf62
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
package yap

import (
"context"
"io/fs"
"net/http"

"github.com/qiniu/x/http/fsx"
)

const (
Expand Down Expand Up @@ -83,8 +86,18 @@ func (p App) Static__0(pattern string, dir ...fs.FS) {
p.Static(pattern, dir...)
}

// Static serves static files from a http file system scheme (url).
// See https://pkg.go.dev/github.com/qiniu/x/http/fsx for more information.
func (p App) Static__1(pattern string, ctx context.Context, url string) (closer fsx.Closer, err error) {
fs, closer, err := fsx.Open(ctx, url)
if err == nil {
p.StaticHttp(pattern, fs)
}
return
}

// Static serves static files from a http file system.
func (p App) Static__1(pattern string, fs http.FileSystem) {
func (p App) Static__2(pattern string, fs http.FileSystem) {
p.StaticHttp(pattern, fs)
}

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/goplus/yap

go 1.18

require github.com/qiniu/x v1.13.2
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/qiniu/x v1.13.2 h1:mgWOfB9Rpk6AEtlBoObZVxH+b2FHSntYrxc4KX5Ta98=
github.com/qiniu/x v1.13.2/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E=

0 comments on commit ffebf62

Please sign in to comment.