Skip to content

Commit

Permalink
Serve raw content length for static assets (#217)
Browse files Browse the repository at this point in the history
* feat: serve raw content length

* fix: remove unused import
  • Loading branch information
x1unix committed May 11, 2023
1 parent 72a97b5 commit 634fc47
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion internal/langserver/spa.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path"
"path/filepath"
"strconv"
"strings"
)

Expand Down Expand Up @@ -54,13 +55,15 @@ func (fs *SpaFileServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
name := path.Join(dir, filepath.FromSlash(upath))

//check if file exists
if _, err := os.Stat(name); err != nil {
s, err := os.Stat(name)
if err != nil {
if os.IsNotExist(err) {
fs.NotFoundHandler.ServeHTTP(rw, r)
return
}
}

rw.Header().Set(rawContentLengthHeader, strconv.FormatInt(s.Size(), 10))
http.ServeFile(rw, r, name)
}

Expand Down
3 changes: 2 additions & 1 deletion web/src/services/gorepl/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {EvalEventKind} from "../api";
import {ConsoleStreamType} from "~/lib/gowasm/bindings/stdio";
import {
newErrorAction,
newLoadingAction, newProgramFinishAction, newProgramStartAction,
newProgramFinishAction,
newProgramStartAction,
newProgramWriteAction,
} from "~/store/actions";
import {DispatchFn, StateProvider} from "~/store/helpers";
Expand Down
2 changes: 1 addition & 1 deletion web/src/store/dispatchers/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {isDarkModeEnabled} from "~/utils/theme";
import config, {RunTargetConfig} from '~/services/config';

import { Dispatcher, StateDispatch } from "./utils";
import { Dispatcher } from "./utils";
import {PanelState, SettingsState} from "../state";
import { StateProvider, DispatchFn } from "../helpers";
import {
Expand Down
2 changes: 1 addition & 1 deletion web/src/store/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { connectRouter } from 'connected-react-router';
import { combineReducers } from 'redux';
import {editor} from 'monaco-editor';

import { RunResponse, EvalEvent } from '~/services/api';
import { EvalEvent } from '~/services/api';
import config, {
MonacoSettings,
RunTargetConfig
Expand Down

0 comments on commit 634fc47

Please sign in to comment.