Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yap with x/http/fsx #27

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=