1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
cowyo/cmd/herdyo/herdyo.go
2018-05-27 21:49:55 +10:00

41 lines
921 B
Go

package main
import (
"net/http"
"strings"
"github.com/gin-contrib/sessions"
"github.com/schollz/cowyo/server"
)
func main() {
store := sessions.NewCookieStore([]byte("secret"))
first := server.Site{
PathToData: "site1",
Debounce: 500,
SessionStore: store,
AllowInsecure: true,
Fileuploads: true,
MaxUploadSize: 2,
}.Router()
second := server.Site{
PathToData: "site2",
Debounce: 500,
SessionStore: store,
AllowInsecure: true,
Fileuploads: true,
MaxUploadSize: 2,
}.Router()
panic(http.ListenAndServe("localhost:8000", http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.Host, "first") {
first.ServeHTTP(rw, r)
} else if strings.HasPrefix(r.Host, "second") {
second.ServeHTTP(rw, r)
} else {
http.NotFound(rw, r)
}
})))
}