44 lines
527 B
Go
44 lines
527 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"pageswiki/internal/store"
|
|
)
|
|
|
|
type RequestContext struct {
|
|
District *store.District
|
|
}
|
|
|
|
func (s *Server) BuildRequestContext(
|
|
r *http.Request,
|
|
) *RequestContext {
|
|
|
|
return &RequestContext{
|
|
District: s.currentDistrict(),
|
|
}
|
|
}
|
|
|
|
func (s *Server) renderWithContext(
|
|
w http.ResponseWriter,
|
|
r *http.Request,
|
|
name string,
|
|
data map[string]any,
|
|
) {
|
|
|
|
if data == nil {
|
|
data = map[string]any{}
|
|
}
|
|
|
|
data["Context"] =
|
|
s.BuildRequestContext(
|
|
r,
|
|
)
|
|
|
|
s.render(
|
|
w,
|
|
name,
|
|
data,
|
|
)
|
|
}
|