support .well-known dir
This commit is contained in:
parent
422f14199e
commit
07d12326f0
2 changed files with 15 additions and 3 deletions
15
lib/web.go
15
lib/web.go
|
|
@ -54,13 +54,24 @@ func (f *Forgejo) GetFile(ctx context.Context, headers map[string]string, user,
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func UseAPI(bind string, f *Forgejo) (*http.Server, error) {
|
||||
func UseAPI(bind, wellKnown string, f *Forgejo) (*http.Server, error) {
|
||||
if f == nil {
|
||||
return nil, errors.New("forgejo is nil")
|
||||
}
|
||||
mux := http.NewServeMux()
|
||||
if wellKnown != "" {
|
||||
mux.Handle(
|
||||
"/.well-known/",
|
||||
http.StripPrefix(
|
||||
"/.well-known/",
|
||||
http.FileServer(http.Dir(wellKnown)),
|
||||
),
|
||||
)
|
||||
}
|
||||
mux.HandleFunc("/", f.handle)
|
||||
s := &http.Server{
|
||||
Addr: bind,
|
||||
Handler: http.HandlerFunc(f.handle),
|
||||
Handler: mux,
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue