aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/static.go
blob: 9f312f41f09ef14dad4649bfaa0b76d61f8abb5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package handler

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

	"git.gabrielgio.me/cerrado/static"
)

func NewStaticHander(prefix string) (http.Handler, error) {
	staticFs, err := fs.Sub(static.Static, ".")
	if err != nil {
		return nil, err
	}

	handler := http.StripPrefix(prefix, http.FileServer(http.FS(staticFs)))
	return handler, nil
}