webhandle

package module
v0.0.0-...-8f08e3a Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 11 Imported by: 5

README

DEPRECATED

webhandle Build Status GoDoc

One way to serve webpages with onthefly and mux.

This is an experimental package and the overall design could be cleaner.

Online API Documentation

godoc.org

Features and limitations

  • Webhandle can take a *onthefly.Page and publish both the HTML and CSS together, by listening to HTTP GET requests.
  • gorilla/mux is used for some of the functions.

General information

  • Version: 0.1.1
  • License: MIT
  • Alexander F. Rødseth

Documentation

Overview

Serve webpages with onthefly and http

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackButton

func BackButton() string

Button for going back in history

func CleanUserInput

func CleanUserInput(val string) string

func GetFormParam

func GetFormParam(req *http.Request, key string) string

Returns a form parameter, or an empty string

func GetLast

func GetLast(url *url.URL) string

Get the last value from an url. /hi/there/qwerty returns qwerty

func GetParam

func GetParam(req *http.Request, key string) string

Returns an url parameter, or an empty string

func GetVal

func GetVal(url *url.URL, pos int) string

Get a value from an url. /hi/there/asdf with pos 2 returns asdf

func HTMLPageRedirect

func HTMLPageRedirect(url string) string

HTML page that redirects to an url by using JavaScript

func HostPortSplit

func HostPortSplit(s string) (string, string)

Split a string into two strings at the colon If there's no colon, return the string and an empty string

func LoginForm

func LoginForm() string

Generic login form, not a complete html page. Sends a POST request to /login. Passes "password". (Only "name=" fields). Remember to don't send passwords in plaintext. Use https.

func Message

func Message(title, msg string) string

HTML page that just displays a message

func MessageOKback

func MessageOKback(title, msg string) string

Message page where the ok button goes one back in history by using JavaScript

func MessageOKurl

func MessageOKurl(title, msg, url string) string

Message page where the ok button goes to a given url using JavaScript

func Publish

func Publish(r *mux.Router, url, filename string)

Serve a static file

func PublishFile

func PublishFile(r *mux.Router, url, filename string)

Takes an url and a filename and offers that file at the given url

func PublishPage

func PublishPage(r *mux.Router, htmlurl, cssurl string, buildfunction func(string) *Page)

Expose the HTML and CSS generated by a page building function to the two given urls

func PublishRootFile

func PublishRootFile(r *mux.Router, filename string)

Takes a filename and offers that file at the root url

func RegisterForm

func RegisterForm() string

Generic registration form, not a complete html page. Sends a POST request to /register. Passes "password1", "password2" and "email". (Only "name=" fields). Remember to don't send passwords in plaintext. Use https.

func Ret

func Ret(w http.ResponseWriter, s string)

Write the given string to the response writer. Convenience function.

func TableCell

func TableCell(b bool) string

func TruthValue

func TruthValue(val string) bool

Converts "true" or "false" to a bool

Types

type HTTPHandler

type HTTPHandler func(http.ResponseWriter, *http.Request)

func File

func File(filename string) HTTPHandler

Takes a filename and returns a function that can handle the request

func GenerateCSS

func GenerateCSS(page *Page) HTTPHandler

Create a web.go compatible function that returns a string that is the CSS for this page

func GenerateErrorHandle

func GenerateErrorHandle(errorfilename string) HTTPHandler

Creates a page based on the contents of "error.log". Useful for showing compile errors while creating an application.

func GenerateHTML

func GenerateHTML(page *Page) HTTPHandler

Create a web.go compatible function that returns a string that is the HTML for this page

func GenerateXML

func GenerateXML(page *Page) HTTPHandler

Create a web.go compatible function that returns a string that is the XML for this page

func NotFound

func NotFound(val string) HTTPHandler

Handles pages that are not found

type SimpleContextHandle

type SimpleContextHandle func(w http.ResponseWriter, r *http.Request)

type TemplateValueGenerator

type TemplateValueGenerator func(w http.ResponseWriter, r *http.Request) TemplateValues

type WebHandle

type WebHandle func(val string) (w http.ResponseWriter, r *http.Request)

Various function signatures for handling requests

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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