Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
ab7c4e72
Unverified
Commit
ab7c4e72
authored
3 years ago
by
gadotroee
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
no message (#253)
parent
e25e7925
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
agent/main.go
+12
-0
agent/main.go
with
12 additions
and
0 deletions
+12
-0
agent/main.go
+
12
-
0
View file @
ab7c4e72
...
...
@@ -107,6 +107,7 @@ func hostApi(socketHarOutputChannel chan<- *tap.OutputChannelItem) {
SocketHarOutChannel
:
socketHarOutputChannel
,
}
app
.
Use
(
DisableRootStaticCache
())
app
.
Use
(
static
.
ServeRoot
(
"/"
,
"./site"
))
app
.
Use
(
CORSMiddleware
())
// This has to be called after the static middleware, does not work if its called before
...
...
@@ -119,6 +120,17 @@ func hostApi(socketHarOutputChannel chan<- *tap.OutputChannelItem) {
utils
.
StartServer
(
app
)
}
func
DisableRootStaticCache
()
gin
.
HandlerFunc
{
return
func
(
c
*
gin
.
Context
)
{
if
c
.
Request
.
RequestURI
==
"/"
{
// Disable cache only for the main static route
c
.
Writer
.
Header
()
.
Set
(
"Cache-Control"
,
"no-store"
)
}
c
.
Next
()
}
}
func
CORSMiddleware
()
gin
.
HandlerFunc
{
return
func
(
c
*
gin
.
Context
)
{
c
.
Writer
.
Header
()
.
Set
(
"Access-Control-Allow-Origin"
,
"*"
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help