♻️ 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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
|
@ -104,7 +103,7 @@ func NewApp(ctx context.Context, config *domain.Config) (*App, error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := staticer.Do(r.Context(), r.URL.Path)
|
res, err := staticer.Do(r.Context(), r.URL.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, fs.ErrNotExist) {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
@ -117,7 +116,7 @@ func NewApp(ctx context.Context, config *domain.Config) (*App, error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
http.ServeContent(w, r, f.LogicalName(), f.Updated, bytes.NewReader(f.Content))
|
http.ServeContent(w, r, res.Name(), domain.ResourceModTime(res), res)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue