Documentation
¶
Overview ¶
Package server provides support for hosting, running, and handling a local server
Index ¶
- Constants
- func CopyFile(source string, destination string) (err error)
- func DirectorySetup(dirpath string, mode os.FileMode)
- func DirectoryTeardown(dirpath string)
- func FormatValue(input string, method string) (output string)
- func ProcessFormPrimaryRequest(w http.ResponseWriter, r *http.Request)
- func ProcessRootRequest(w http.ResponseWriter, r *http.Request)
- func SetupCloseHandler()
- func UploadFile(file multipart.File, header *multipart.FileHeader) (path string, err error)
- type Form
- func (f *Form) GetOut(filename string) (path string)
- func (f *Form) GetTemplate(filename string) (path string)
- func (f *Form) OutDOCX() (path string)
- func (f *Form) OutDir() (path string)
- func (f *Form) OutHTML() (path string)
- func (f *Form) OutImages() (path string)
- func (f *Form) OutSCSS() (path string)
- func (f *Form) SetupOutput(name string)
- func (f *Form) TemplateDOCX() (path string)
- func (f *Form) TemplateHTML() (path string)
- func (f *Form) TemplateSCSS() (path string)
- type FormOutput
- type FormPrimary
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) GetTemplate ¶
GetTemplate returns the path to the template file under the name filename.
func (*Form) OutDir ¶
OutDir constructs the path (relative to the root directory) to the output directory for the form f.
func (*Form) SetupOutput ¶
SetupOutput creates the output directory for the form f and all necessary subdirectories.
func (*Form) TemplateDOCX ¶
TemplateDOCX returns the path to the template Word Document (DOCX).
func (*Form) TemplateHTML ¶
TemplateHTML returns the path to the template HTML Document.
func (*Form) TemplateSCSS ¶
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. |