StaticFileHandler
Overview
StaticFileHandler servers static file.
Config yaml format becomes like below. And the resource specific spec is defined in in the proto format shown in the Resource Definition.
apiVersion: core/v1
kind: StaticFileHandler
metadata:
name: "default"
namespace: "default"
spec: {}
Resource Definition
StaticFileHandler is defined in the proto/core/v1/static.proto
syntax = "proto3";
package core.v1;
import "buf/validate/validate.proto";
import "core/v1/http.proto";
import "kernel/resource.proto";
option go_package = "github.com/aileron-gateway/aileron-gateway/apis/core/v1";
// StaticFileHandler resource definition.
// apiVersion="core/v1", kind="StaticFileHandler".
message StaticFileHandler {
string APIVersion = 1 [json_name = "apiVersion"];
string Kind = 2 [json_name = "kind"];
kernel.Metadata Metadata = 3 [json_name = "metadata"];
StaticFileHandlerSpec Spec = 4 [json_name = "spec"];
}
// StaticFileHandlerSpec is the specifications for the StaticFileHandler object.
message StaticFileHandlerSpec {
// [OPTIONAL]
// ErrorHandler is the reference to a ErrorHandler object.
// Referred object must implement ErrorHandler interface.
// Default error handler is used when not set.
kernel.Reference ErrorHandler = 1 [json_name = "errorHandler"];
// [OPTIONAL]
// Patterns is path patterns that this handler
// is registered to a server.
// Default is not set.
repeated string Patterns = 2 [json_name = "patterns", (buf.validate.field).repeated.unique = true];
// [OPTIONA]
// Methods is the list of HTTP method this handler can handle.
// Note that it depends on the multiplexer, or HTTP router,
// that the server uses if this field is used or not.
// Default is not set.
repeated HTTPMethod Methods = 3 [json_name = "methods", (buf.validate.field).repeated.unique = true];
// [OPTIONAL]
// RootDir is the root directry path
// that is serverd by this static file server.
// If not set, the current working directory "./" will be used.
// Default is not set.
string RootDir = 4 [json_name = "rootDir"];
// [OPTIONAL]
// StripPrefix is the prefix string to strip from the requested path.
// For example, set "/foo/bar" to get "content.json" with the path "/foo/bar/content.json".
// Default is not set.
string StripPrefix = 5 [json_name = "stripPrefix"];
// [OPTIONAL]
// EnableListing is flag to enable directory listing under RootDir.
// Setting this true can make the gateway vulnerable to directory listing attack.
// Do not set this unless you know what you are doing.
// Default is [false].
bool EnableListing = 6 [json_name = "enableListing"];
// [OPTIONAL]
// Header is the key-value pairs of HTTP headers
// which are added to the all responses.
// For example, headers for cache controls should be considered.
// Content-Type header is recommended to be set when serving the same type contents
// to avoid content detection in the gateway from the stand point view of performance.
// Default is not set.
map<string, string> Header = 7 [json_name = "header"];
}
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.