Add interactive test page.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Captain ALM 2022-07-15 12:43:06 +01:00
parent 42dd0259af
commit ac08289073
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
3 changed files with 43 additions and 1 deletions

View File

@ -1,10 +1,13 @@
package pageHandler
import "golang.captainalm.com/cityuni-webserver/pageHandler/pages"
var providers map[string]PageProvider
func GetProviders(cacheTemplates bool, dataStorage string) map[string]PageProvider {
if providers == nil {
providers = make(map[string]PageProvider)
providers["/test.go"] = pages.NewTestPage() //Test Page
//Add the providers in the pages sub package
}
return providers

View File

@ -0,0 +1,39 @@
package pages
import (
"net/url"
"time"
)
var startTime = time.Now()
func NewTestPage() *TestPage {
return &TestPage{}
}
type TestPage struct {
}
func (tp *TestPage) GetPath() string {
return "/test.go"
}
func (tp *TestPage) GetSupportedURLParameters() []string {
return []string{"test"}
}
func (tp *TestPage) GetLastModified() time.Time {
return startTime
}
func (tp *TestPage) GetContents(urlParameters url.Values) (contentType string, contents []byte) {
if val, ok := urlParameters["test"]; ok {
if len(val) > 0 {
return "text/plain", ([]byte)("Testing!\r\n" + val[0])
}
}
return "text/plain", ([]byte)("Testing!")
}
func (tp *TestPage) PurgeTemplate() {
}