server

package
v0.0.0-...-0408a65 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package server provides support for hosting, running, and handling a local server

Index

Constants

View Source
const (
	PORT int = 8080 // the localhost port served

	OUTPUTDIRECTORY   string = "out/"             // holds all output files generated at runtime
	TEMPLATEDIRECTORY string = "server/templates" // holds all output template files
	TEMPDIRECTORY     string = "temp/"            // holds all temporary files generated at runtime

	FILEMODE os.FileMode = 0755 // the program-specific defualt permission bits
)

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(source string, destination string) (err error)

CopyFile copies the contents of the file located at source to a new file created at destination.

Raises any errors encountered while copying the source file contents to the destination file.

func DirectorySetup

func DirectorySetup(dirpath string, mode os.FileMode)

DirectorySetup creates an empty directory at dirpath using the file mode defined by mode. DirectoryTeardown is first called to remove the target directory and its contents, if it already exists.

Raises any errors encountered while creating the new directory.

func DirectoryTeardown

func DirectoryTeardown(dirpath string)

DirectoryTeardown removes the directory at dirpath and all its contents, regardless of whether the directory exists or no.

Raises any errors encountered while removing the directory.

func FormatValue

func FormatValue(input string, method string) (output string)

FormatValue applies to input the string operation corresponding to method. The modified string is returned as output.

func ProcessFormPrimaryRequest

func ProcessFormPrimaryRequest(w http.ResponseWriter, r *http.Request)

ProcessFormPrimaryRequest processes and responds to all POST requests made to the form `form#primary` ("/forms/primary"). Only POST requests are supported; raises an error if other request types are received.

Raises any errors encountered while handling POST requests.

func ProcessRootRequest

func ProcessRootRequest(w http.ResponseWriter, r *http.Request)

ProcessRootRequest processes and responds to all requests made to the root URL ("/"). Only GET requests are supported; raises an error if other request types are received.

func SetupCloseHandler

func SetupCloseHandler()

SetupCloseHandler cleans up the local file system, called when the program is about to be terminated. A goroutine listens for OS interrupt errors and calls DirectoryTeardown if one is detected.

func UploadFile

func UploadFile(file multipart.File, header *multipart.FileHeader) (path string, err error)

UploadFile saves the contents of file to the local file system, at the path determined by header (header.Filename).

Raises any errors encountered while copying the file contents to the local file system.

Types

type Form

type Form struct {
	Name string // Field element 'name' attribute
}

func (*Form) GetOut

func (f *Form) GetOut(filename string) (path string)

GetOut returns the path to the output file under the name filename.

func (*Form) GetTemplate

func (f *Form) GetTemplate(filename string) (path string)

GetTemplate returns the path to the template file under the name filename.

func (*Form) OutDOCX

func (f *Form) OutDOCX() (path string)

OutDOCX returns the path to the output Word Document (DOCX).

func (*Form) OutDir

func (f *Form) OutDir() (path string)

OutDir constructs the path (relative to the root directory) to the output directory for the form f.

func (*Form) OutHTML

func (f *Form) OutHTML() (path string)

OutHTML returns the path to the output HTML Document.

func (*Form) OutImages

func (f *Form) OutImages() (path string)

OutImages returns the path to the output images/ directory.

func (*Form) OutSCSS

func (f *Form) OutSCSS() (path string)

OutSCSS returns the path to the output CSS stylesheet.

func (*Form) SetupOutput

func (f *Form) SetupOutput(name string)

SetupOutput creates the output directory for the form f and all necessary subdirectories.

func (*Form) TemplateDOCX

func (f *Form) TemplateDOCX() (path string)

TemplateDOCX returns the path to the template Word Document (DOCX).

func (*Form) TemplateHTML

func (f *Form) TemplateHTML() (path string)

TemplateHTML returns the path to the template HTML Document.

func (*Form) TemplateSCSS

func (f *Form) TemplateSCSS() (path string)

TemplateSCSS returns the path to the template CSS stylesheet.

type FormOutput

type FormOutput interface {
	// contains filtered or unexported methods
}

type FormPrimary

type FormPrimary struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package docx handles writing Word Document (.DOCX) output.
Package docx handles writing Word Document (.DOCX) output.
Package html handles writing HTML Document (.HTML) output.
Package html handles writing HTML Document (.HTML) output.
Package scss handles writing SCSS Document (.SCSS) output.
Package scss handles writing SCSS Document (.SCSS) output.

Jump to

Keyboard shortcuts

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