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
1syntax = "proto3";
2package core.v1;
3
4import "buf/validate/validate.proto";
5import "core/v1/http.proto";
6import "kernel/resource.proto";
7
8option go_package = "github.com/aileron-gateway/aileron-gateway/apis/core/v1";
9
10// StaticFileHandler resource definition.
11// apiVersion="core/v1", kind="StaticFileHandler".
12message StaticFileHandler {
13 string APIVersion = 1 [json_name = "apiVersion"];
14 string Kind = 2 [json_name = "kind"];
15 kernel.Metadata Metadata = 3 [json_name = "metadata"];
16 StaticFileHandlerSpec Spec = 4 [json_name = "spec"];
17}
18
19// StaticFileHandlerSpec is the specifications for the StaticFileHandler object.
20message StaticFileHandlerSpec {
21 // [OPTIONAL]
22 // ErrorHandler is the reference to a ErrorHandler object.
23 // Referred object must implement ErrorHandler interface.
24 // Default error handler is used when not set.
25 kernel.Reference ErrorHandler = 1 [json_name = "errorHandler"];
26
27 // [OPTIONAL]
28 // Patterns is path patterns that this handler
29 // is registered to a server.
30 // Default is not set.
31 repeated string Patterns = 2 [json_name = "patterns", (buf.validate.field).repeated.unique = true];
32
33 // [OPTIONA]
34 // Methods is the list of HTTP method this handler can handle.
35 // Note that it depends on the multiplexer, or HTTP router,
36 // that the server uses if this field is used or not.
37 // Default is not set.
38 repeated HTTPMethod Methods = 3 [json_name = "methods", (buf.validate.field).repeated.unique = true];
39
40 // [OPTIONAL]
41 // RootDir is the root directry path
42 // that is serverd by this static file server.
43 // If not set, the current working directory "./" will be used.
44 // Default is not set.
45 string RootDir = 4 [json_name = "rootDir"];
46
47 // [OPTIONAL]
48 // StripPrefix is the prefix string to strip from the requested path.
49 // For example, set "/foo/bar" to get "content.json" with the path "/foo/bar/content.json".
50 // Default is not set.
51 string StripPrefix = 5 [json_name = "stripPrefix"];
52
53 // [OPTIONAL]
54 // EnableListing is flag to enable directory listing under RootDir.
55 // Setting this true can make the gateway vulnerable to directory listing attack.
56 // Do not set this unless you know what you are doing.
57 // Default is [false].
58 bool EnableListing = 6 [json_name = "enableListing"];
59
60 // [OPTIONAL]
61 // Header is the key-value pairs of HTTP headers
62 // which are added to the all responses.
63 // For example, headers for cache controls should be considered.
64 // Content-Type header is recommended to be set when serving the same type contents
65 // to avoid content detection in the gateway from the stand point view of performance.
66 // Default is not set.
67 map<string, string> Header = 7 [json_name = "header"];
68}
フィードバック
このページは役に立ちましたか?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.