Skip to content

Ability to serve static files for paths different from / #911

Closed
@botanegg

Description

@botanegg

Add a description

For HttpHandlerStatic we cannot serve files for path different from root

Example, for next static_config:

    fs-cache-main:
      dir: /var/www          # Path to the directory with files
      update-period: 10s        # update cache each N seconds
      fs-task-processor: fs-task-processor  # Run it on blocking task processor

    handler-static: # Finally! Static handler.
      fs-cache-component: fs-cache-main
      path: /sub_path/d1/d2/d3/*                  # Registering handlers '/*' find files.
      method: GET              # Handle only GET requests.
      task_processor: main-task-processor  # Run it on CPU bound task processor

For request http://HOSTNAME/sub_path/d1/d2/d3/filename we will seach file /var/www/sub_path/d1/d2/d3/filename instead of intuitive /var/www/filename

It is due to HttpHandlerStatic using request.GetRequestPath() as path to search files in fs-cache:dir
To make possible to work on other base paths, we need to change file search path to GetPathArg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions