MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / WebRequest

Method WebRequest

internal/plugins/plugins.go:184–212  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

182}
183
184func (p pluginRegistry) WebRequest(r *http.Request) (html string, templateData map[string]any, ok bool) {
185
186 reqPath := filepath.Clean(r.URL.Path) // Example: / or /info/faq
187
188 rootFilePath := `html/public/`
189 for _, pItem := range p {
190
191 pageData, ok := pItem.Web.pages[reqPath]
192 if !ok {
193 continue
194 }
195
196 b, err := pItem.files.ReadFile(util.FilePath(rootFilePath, pageData.Filepath))
197
198 if err != nil {
199 continue
200 }
201
202 html = string(b)
203
204 if pageData.DataFunction != nil {
205 templateData = pageData.DataFunction(r)
206 }
207
208 return html, templateData, true
209 }
210
211 return html, templateData, false
212}
213
214// Iterator for all plugin file systems.
215// This allows you to process each one individually.

Callers

nothing calls this directly

Calls 2

FilePathFunction · 0.92
ReadFileMethod · 0.45

Tested by

no test coverage detected