controllers

package
v0.0.0-...-001a92f Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Static

type Static struct {
	*revel.Controller
}

func (Static) Serve

func (c Static) Serve(prefix, filepath string) revel.Result

This method handles requests for files. The supplied prefix may be absolute or relative. If the prefix is relative it is assumed to be relative to the application directory. The filepath may either be just a file or an additional filepath to search for the given file. This response may return the following responses in the event of an error or invalid request;

403(Forbidden): If the prefix filepath combination results in a directory.
404(Not found): If the prefix and filepath combination results in a non-existent file.
500(Internal Server Error): There are a few edge cases that would likely indicate some configuration error outside of revel.

Note that when defining routes in routes/conf the parameters must not have spaces around the comma.

Bad:  Static.Serve("public/img", "favicon.png")
Good: Static.Serve("public/img","favicon.png")

Examples: Serving a directory

Route (conf/routes):
  GET /public/{<.*>filepath} Static.Serve("public")
Request:
  public/js/sessvars.js
Calls
  Static.Serve("public","js/sessvars.js")

Serving a file

Route (conf/routes):
  GET /favicon.ico Static.Serve("public/img","favicon.png")
Request:
  favicon.ico
Calls:
  Static.Serve("public/img", "favicon.png")

func (Static) ServeModule

func (c Static) ServeModule(moduleName, prefix, filepath string) revel.Result

This method allows modules to serve binary files. The parameters are the same as Static.Serve with the additional module name pre-pended to the list of arguments.

Jump to

Keyboard shortcuts

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