API Docs for:
Show:

server_com_static_http Class

Module: com_static_http

Provides the REST server.

Methods

config

(
  • path
)

Configurates the REST server properties by a configuration file. The file must use the JSON syntax.

The method can throw an Exception.

Parameters:

  • path String

    The path of the configuration file

copyFile

(
  • srcpath
  • dstpath
  • cb
)

Copy given file path to a local file inside the webroot directory.

Parameters:

  • srcpath String

    Original file path

  • dstpath String

    Name of symlink

  • cb Function

    The callback function

httpServerCb

(
  • req
  • res
)
static

The callback function of the create http server invocation. First it looks the static resource into the webroot and then into the customWebroot.

Parameters:

  • req Object

    The http request

  • res Object

    The http response

saveFile

(
  • dstpath
  • data
)

Save given data to a file inside the webroot directory. If the file exists it will be overwritten.

Parameters:

  • dstpath String

    The path of destination file

  • data Object

    Raw data to save inside the file

setCompUtil

(
  • comp
)

Sets the utility architect component.

Parameters:

  • comp Object

    The utility architect component.

setLogger

(
  • log
)
static

Set the logger to be used.

Parameters:

  • log Object

    The logger object. It must have at least three methods: info, warn and error as console object.

start

() static

Start the REST server.

Properties

address

String private

Listening address of the REST server. It can be customized by the configuration file.

Default: "localhost"

compUtil

Object private

The utility architect component.

customFileStaticRoot

Object private

The node-static server instance for customized static files created by the user.

customWebroot

String private

The root directory of the custom static files created by the user.

fileStaticRoot

Object private

The node-static server instance for default static files.

IDLOG

String private final

The module identifier used by the logger.

Default: [server_com_static_http]

logger

Object private

The logger. It must have at least three methods: info, warn and error.

Default: console

port

String private

Listening port of the REST server. It can be customized by the configuration file.

webroot

String private

The root directory of the static files to serve.

Default: "static"