♻️ Simplify static resources usage in main
This commit is contained in:
parent
962317d0c3
commit
369233a83e
5
main.go
5
main.go
|
@ -5,7 +5,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
|
@ -104,7 +103,7 @@ func NewApp(ctx context.Context, config *domain.Config) (*App, error) {
|
|||
return
|
||||
}
|
||||
|
||||
f, err := staticer.Do(r.Context(), r.URL.Path)
|
||||
res, err := staticer.Do(r.Context(), r.URL.Path)
|
||||
if err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
|
@ -117,7 +116,7 @@ func NewApp(ctx context.Context, config *domain.Config) (*App, error) {
|
|||
return
|
||||
}
|
||||
|
||||
http.ServeContent(w, r, f.LogicalName(), f.Updated, bytes.NewReader(f.Content))
|
||||
http.ServeContent(w, r, res.Name(), domain.ResourceModTime(res), res)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue