aboutsummaryrefslogtreecommitdiffstats
path: root/yql/tools/yqlrun/http/assets_servlet.h
blob: 688270769f62d9ac27f224852ab54baa43257529 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include "servlet.h"


namespace NYql {
namespace NHttp {

///////////////////////////////////////////////////////////////////////////////
// TAssetsServlet
///////////////////////////////////////////////////////////////////////////////
class TAssetsServlet: public IServlet
{
    struct TAsset {
        TBlob Data;
        time_t LastModified;
        const char* ContentType;
    };

public:
    TAssetsServlet(
            const TString& baseUrl,
            const TString& baseDir,
            const TString& indexFile);

    void DoGet(const TRequest& req, TResponse& resp) const override final;

private:
    TString SafeFilePath(const TString& basePath, TStringBuf reqPath) const;
    bool IsCachedOnClient(const TRequest& req, const TAsset& asset) const;
    void LoadAsset(const TRequest& req, TAsset* asset) const;

private:
    TString BaseUrl_;
    TString BaseDir_;
    TString IndexFile_;
};


} // namspace NNttp
} // namspace NYql