@ui5/server/middleware/MiddlewareUtil

@ui5/server/middleware/MiddlewareUtil

Convenience functions for UI5 Server middleware. An instance of this class is passed to every standard UI5 Server middleware. Custom middleware that define a specification version >= 2.0 will also receive an instance of this class as part of the parameters of their create-middleware function. The set of functions that can be accessed by a custom middleware depends on the specification version defined for the extension.

Members

resourceFactory :@ui5/project/build/helpers/MiddlewareUtill~resourceFactory

Description:
  • Provides limited access to @ui5/fs/resourceFactory functions

    This attribute is only available to custom server middleware extensions defining Specification Version 3.0 and above.
Source:
Provides limited access to @ui5/fs/resourceFactory functions

This attribute is only available to custom server middleware extensions defining Specification Version 3.0 and above.
Type:

Methods

getDependencies(projectNameopt) → {Array.<string>}

Description:
  • Retrieve a list of direct dependencies of a given project from the dependency graph. Note that this list does not include transitive dependencies.

    This method is only available to custom server middleware extensions defining Specification Version 3.0 and above.
Source:
Parameters:
Name Type Attributes Description
projectName string <optional>
Name of the project to retrieve. Defaults to the name of the current root project
Throws:
If the requested project is unknown to the graph
Type
Error
Returns:
Names of all direct dependencies
Type
Array.<string>

getMimeInfo(resourcePath) → {@ui5/server/middleware/MiddlewareUtil.MimeInfo}

Description:
  • Returns MIME information derived from a given resource path.

    This method is only available to custom middleware extensions defining Specification Version 2.0 and above.
Source:
Parameters:
Name Type Description
resourcePath object
Returns:
Type
@ui5/server/middleware/MiddlewareUtil.MimeInfo

getPathname(req) → {string}

Description:
  • Returns the pathname of a given request. Any escape sequences will be decoded.

    This method is only available to custom middleware extensions defining Specification Version 2.0 and above.
Source:
Parameters:
Name Type Description
req object Request object
Returns:
Pathname of the given request
Type
string

getProject(projectNameOrResourceopt) → {@ui5/project/build/helpers/MiddlewareUtill~ProjectInterface|undefined}

Description:
  • Retrieve a single project from the dependency graph

    This method is only available to custom server middleware extensions defining Specification Version 3.0 and above.
Source:
Parameters:
Name Type Attributes Description
projectNameOrResource string | @ui5/fs/Resource <optional>
Name of the project to retrieve or a Resource instance to retrieve the associated project for. Defaults to the name of the current root project
Returns:
Specification Version-dependent interface to the Project instance or undefined if the project name is unknown or the provided resource is not associated with any project.
Type
@ui5/project/build/helpers/MiddlewareUtill~ProjectInterface | undefined

Type Definitions

MimeInfo

Description:
  • MIME Info
Source:
Properties:
Name Type Description
type string Detected content-type for the given resource path
charset string Default charset for the detected content-type
contentType string Calculated content-type header value
MIME Info
Type:
  • object
Example
const mimeInfo = {
	"type": "text/html",
	"charset": "utf-8",
	"contentType": "text/html; charset=utf-8"
};