-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhutplate.go
40 lines (33 loc) · 796 Bytes
/
hutplate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package hutplate
import (
"github.com/gorilla/sessions"
"net/http"
)
type Http struct {
*http.Request
Response response
Session session
Auth Auth
}
type configuration struct {
GetUserWithId func(id interface{}) interface{}
GetUserWithCred func(credential interface{}) (interface{}, string)
ErrorHandler func(err error, hut Http)
SessionStore *sessions.Store
SessionSecretKey string
SessionDirectory string
}
var Config configuration
func NewHttp(responseWriter http.ResponseWriter, request *http.Request) Http {
session := NewSession(request, responseWriter, Config.SessionStore)
r := newResponse(responseWriter, request, session)
newHttp := Http{
Request: request,
Response: r,
Session: session,
Auth: Auth{
session,
},
}
return newHttp
}