serve public
This commit is contained in:
parent
410d0fc587
commit
8eabde60fd
9
main.go
9
main.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"gitlab.com/zephyrtronium/sq"
|
"gitlab.com/zephyrtronium/sq"
|
||||||
@ -14,6 +15,11 @@ import (
|
|||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
addr = os.Getenv("SHOTGUN_HTTP")
|
||||||
|
public = os.Getenv("SHOTGUN_PUBLIC")
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sessiondb, err := sq.Open("sqlite", ":memory:")
|
sessiondb, err := sq.Open("sqlite", ":memory:")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -40,5 +46,6 @@ func main() {
|
|||||||
r.Post("/user/login", s.Login)
|
r.Post("/user/login", s.Login)
|
||||||
r.With(serve.WithSession(sessions)).Get("/user/me", s.Me)
|
r.With(serve.WithSession(sessions)).Get("/user/me", s.Me)
|
||||||
r.With(serve.WithSession(sessions)).Get("/queue", s.Queue)
|
r.With(serve.WithSession(sessions)).Get("/queue", s.Queue)
|
||||||
http.ListenAndServe(":8080", r)
|
r.Method("GET", "/", http.FileServer(http.Dir(public)))
|
||||||
|
http.ListenAndServe(addr, r)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user