web

package
v0.9.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 31 Imported by: 0

README

Web pages

Everything is served from the public html folder (Default: _datafiles/html/public)

The .html extension can be left off of page requests. For example, http://localhost/webclient.html can also be accessed with http://localhost/webclient.

You can add your own files (images, html, css) and they will be served from here as well. For example, add a folder called test and put a test.html in there. You should be able to open it up at http://localhost/test/test.html or http://localhost/test/test

NOTE: .html files are parsed as templates, using the Go text/template package.

NOTE: files beginning with _ such as _header.html cannot be directly requested. Additionally, these files are loaded into memory automatically and parsed with every page request. This is a good place to put template includes (See _header.html, _footer.html and 404.html for an example of what this looks like.

Template variables

There are a few template variables defined for use:

.REQUEST - This is an object containing the web request data. See Request.go for details.

.CONFIG - This is an object containing the MUD config data. See configs.go for details.

.STATS - This object contains a little bit of data about the server. See stats.go for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(wg *sync.WaitGroup, webSocketHandler func(*websocket.Conn))

func RunWithMUDLocked

func RunWithMUDLocked(next http.HandlerFunc) http.HandlerFunc

This wraps the handler functiojn with a game lock (mutex) to keep the mud from Concurrently accessing the same memory

func SetWebPlugin

func SetWebPlugin(wp WebPlugin)

func Shutdown

func Shutdown()

func UpdateStats

func UpdateStats(s Stats)

Returns a copy of the server stats

Types

type Stats

type Stats struct {
	OnlineUsers   []users.OnlineInfo
	TelnetPorts   []int
	WebSocketPort int
}

func GetStats

func GetStats() Stats

Returns a copy of the server stats

func (*Stats) Reset

func (s *Stats) Reset()

type WebNav

type WebNav struct {
	Name   string
	Target string
}

type WebPlugin

type WebPlugin interface {
	NavLinks() map[string]string                                                    // Name=>Path pairs
	WebRequest(r *http.Request) (html string, templateData map[string]any, ok bool) // Get the first handler of a given request
}

type ZoneDetails

type ZoneDetails struct {
	ZoneName  string
	RoomCount int
	AutoScale string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL