modules: github.com/revel/modules/static/app/controllers Index | Files

package controllers

import "github.com/revel/modules/static/app/controllers"

Index

Package Files

static.go

Constants

const (
    B   int64 = 1 << (10 * iota) // ignore first value by assigning to blank identifier
    KB
    MB
    GB
    TB
    PB
    EB
)
const DIR_ICON = "folder.png"
const FILE_ICON = "document.png"
const UP_DIR_ICON = "upfolder.png"

type Static Uses

type Static struct {
    *revel.Controller
}

Static file serving controller

func (Static) Serve Uses

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

Serve 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) ServeDir Uses

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

This function serves out the directory as a browseable folder

func (Static) ServeModule Uses

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

ServeModule 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.

func (Static) ServeModuleDir Uses

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

ServeModule 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.

Package controllers imports 9 packages (graph) and is imported by 10 packages. Updated 2018-09-23. Refresh now. Tools for package owners.