mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-21 22:28:57 +00:00
chore: update resource path setting checks
This commit is contained in:
parent
b9e5e7f2af
commit
bc6a72561c
@ -33,18 +33,22 @@ func (s *ResourceService) Register(g *echo.Group) {
|
||||
Key: store.WorkspaceResourceRelativePath,
|
||||
})
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Failed to workspace resource relative path setting").SetInternal(err)
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "failed to workspace resource relative path setting").SetInternal(err)
|
||||
}
|
||||
if resourceRelativePathSetting == nil || resourceRelativePathSetting.Value == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "found no workspace resource relative path setting")
|
||||
}
|
||||
|
||||
resourceRelativePath := resourceRelativePathSetting.Value
|
||||
resourcePath := fmt.Sprintf("%s/%s", resourceRelativePath, resourceID)
|
||||
buf, err := os.ReadFile(resourcePath)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to read the local resource: %s", resourcePath)).SetInternal(err)
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to read the local resource: %s", resourcePath)).SetInternal(err)
|
||||
}
|
||||
|
||||
kind, err := filetype.Match(buf)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to match the local resource: %s", resourcePath)).SetInternal(err)
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to match the local resource: %s", resourcePath)).SetInternal(err)
|
||||
}
|
||||
resourceMimeType := kind.MIME.Value
|
||||
c.Response().Writer.Header().Set(echo.HeaderCacheControl, "max-age=31536000, immutable")
|
||||
|
@ -59,3 +59,12 @@ CREATE TABLE activity (
|
||||
level TEXT NOT NULL CHECK (level IN ('INFO', 'WARN', 'ERROR')) DEFAULT 'INFO',
|
||||
payload TEXT NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
||||
-- idp
|
||||
CREATE TABLE idp (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
identifier_filter TEXT NOT NULL DEFAULT '',
|
||||
config TEXT NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
8
store/db/migration/prod/0.5/00_idp.sql
Normal file
8
store/db/migration/prod/0.5/00_idp.sql
Normal file
@ -0,0 +1,8 @@
|
||||
-- idp
|
||||
CREATE TABLE idp (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
identifier_filter TEXT NOT NULL DEFAULT '',
|
||||
config TEXT NOT NULL DEFAULT '{}'
|
||||
);
|
@ -59,3 +59,12 @@ CREATE TABLE activity (
|
||||
level TEXT NOT NULL CHECK (level IN ('INFO', 'WARN', 'ERROR')) DEFAULT 'INFO',
|
||||
payload TEXT NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
||||
-- idp
|
||||
CREATE TABLE idp (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
identifier_filter TEXT NOT NULL DEFAULT '',
|
||||
config TEXT NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user