Fix rendering mocks
This commit is contained in:
parent
a0eee3a95f
commit
87fe5ec2e5
2 changed files with 13 additions and 7 deletions
12
sync/mock.go
12
sync/mock.go
|
|
@ -52,13 +52,21 @@ func addMock(r chi.Router, path string, template string) {
|
||||||
})
|
})
|
||||||
r.Get(path, renderMock(template))
|
r.Get(path, renderMock(template))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type contentMock struct {
|
||||||
|
Config contentConfig
|
||||||
|
DistrictName string
|
||||||
|
URLs ContentMockURLs
|
||||||
|
}
|
||||||
|
|
||||||
func renderMock(template_name string) http.HandlerFunc {
|
func renderMock(template_name string) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
code := chi.URLParam(r, "code")
|
code := chi.URLParam(r, "code")
|
||||||
if code == "" {
|
if code == "" {
|
||||||
code = "abc-123"
|
code = "abc-123"
|
||||||
}
|
}
|
||||||
data := ContentMock{
|
data := contentMock{
|
||||||
|
Config: newContentConfig(),
|
||||||
DistrictName: "Delta MVCD",
|
DistrictName: "Delta MVCD",
|
||||||
URLs: ContentMockURLs{
|
URLs: ContentMockURLs{
|
||||||
Dispatch: "/mock/dispatch",
|
Dispatch: "/mock/dispatch",
|
||||||
|
|
@ -83,11 +91,13 @@ func renderMock(template_name string) http.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
type contentMockList struct {
|
type contentMockList struct {
|
||||||
|
Config contentConfig
|
||||||
Mocks []mock
|
Mocks []mock
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderMockList(w http.ResponseWriter, r *http.Request) {
|
func renderMockList(w http.ResponseWriter, r *http.Request) {
|
||||||
data := contentMockList{
|
data := contentMockList{
|
||||||
|
Config: newContentConfig(),
|
||||||
Mocks: mocks,
|
Mocks: mocks,
|
||||||
}
|
}
|
||||||
html.RenderOrError(w, "sync/mock/root.html", data)
|
html.RenderOrError(w, "sync/mock/root.html", data)
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,6 @@ type ContentMockURLs struct {
|
||||||
SettingUser string
|
SettingUser string
|
||||||
SettingUserAdd string
|
SettingUserAdd string
|
||||||
}
|
}
|
||||||
type ContentMock struct {
|
|
||||||
DistrictName string
|
|
||||||
URLs ContentMockURLs
|
|
||||||
}
|
|
||||||
type ContentReportDetail struct {
|
type ContentReportDetail struct {
|
||||||
NextURL string
|
NextURL string
|
||||||
UpdateURL string
|
UpdateURL string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue