first compilable version
This commit is contained in:
parent
6fda229a8e
commit
fc1912bfa9
10 changed files with 188 additions and 88 deletions
|
|
@ -6,15 +6,26 @@ import (
|
|||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/alloc"
|
||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/config"
|
||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/db"
|
||||
)
|
||||
|
||||
func NewContext(w http.ResponseWriter, r *http.Request, log logr.Logger) *Context {
|
||||
type ContextData struct {
|
||||
Alloc *alloc.Alloc
|
||||
DB *db.DB
|
||||
Auth []config.BasicAuth
|
||||
}
|
||||
|
||||
func NewContext(w http.ResponseWriter, r *http.Request, data *ContextData, log logr.Logger) *Context {
|
||||
h := w.Header()
|
||||
h.Set("Content-Type", "application/json")
|
||||
return &Context{
|
||||
Status: http.StatusOK,
|
||||
Request: r,
|
||||
Response: w,
|
||||
Data: data,
|
||||
logger: log,
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +37,9 @@ type Context struct {
|
|||
|
||||
Request *http.Request
|
||||
Response http.ResponseWriter
|
||||
logger logr.Logger
|
||||
|
||||
Data *ContextData
|
||||
logger logr.Logger
|
||||
}
|
||||
|
||||
// Method returns the request method
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue