Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
4a6da917
Commit
4a6da917
authored
Feb 20, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix serve frontend flag
parent
fa62e8b5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
17 deletions
+8
-17
main.go
bin/memos/main.go
+3
-3
profile.go
server/profile/profile.go
+2
-2
server.go
server/server.go
+3
-12
No files found.
bin/memos/main.go
View file @
4a6da917
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
"go.uber.org/zap"
"go.uber.org/zap"
"github.com/usememos/memos/internal/jobs"
"github.com/usememos/memos/internal/jobs"
"github.com/usememos/memos/internal/log"
"github.com/usememos/memos/internal/log"
"github.com/usememos/memos/server"
"github.com/usememos/memos/server"
_profile
"github.com/usememos/memos/server/profile"
_profile
"github.com/usememos/memos/server/profile"
...
@@ -174,16 +173,17 @@ func initConfig() {
...
@@ -174,16 +173,17 @@ func initConfig() {
fmt
.
Printf
(
`---
fmt
.
Printf
(
`---
Server profile
Server profile
version: %s
data: %s
data: %s
dsn: %s
dsn: %s
addr: %s
addr: %s
port: %d
port: %d
mode: %s
mode: %s
driver: %s
driver: %s
version: %s
frontend: %t
metric: %t
metric: %t
---
---
`
,
profile
.
Data
,
profile
.
DSN
,
profile
.
Addr
,
profile
.
Port
,
profile
.
Mode
,
profile
.
Driver
,
profile
.
Version
,
profile
.
Metric
)
`
,
profile
.
Version
,
profile
.
Data
,
profile
.
DSN
,
profile
.
Addr
,
profile
.
Port
,
profile
.
Mode
,
profile
.
Driver
,
profile
.
Frontend
,
profile
.
Metric
)
}
}
func
printGreetings
()
{
func
printGreetings
()
{
...
...
server/profile/profile.go
View file @
4a6da917
...
@@ -30,8 +30,8 @@ type Profile struct {
...
@@ -30,8 +30,8 @@ type Profile struct {
Driver
string
`json:"-"`
Driver
string
`json:"-"`
// Version is the current version of server
// Version is the current version of server
Version
string
`json:"version"`
Version
string
`json:"version"`
//
Serve
Frontend indicate the frontend is enabled or not
// Frontend indicate the frontend is enabled or not
ServeFrontend
bool
`json:"frontend
"`
Frontend
bool
`json:"-
"`
// Metric indicate the metric collection is enabled or not
// Metric indicate the metric collection is enabled or not
Metric
bool
`json:"-"`
Metric
bool
`json:"-"`
}
}
...
...
server/server.go
View file @
4a6da917
...
@@ -59,7 +59,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
...
@@ -59,7 +59,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
e
.
Use
(
CORSMiddleware
())
e
.
Use
(
CORSMiddleware
())
e
.
Use
(
middleware
.
TimeoutWithConfig
(
middleware
.
TimeoutConfig
{
e
.
Use
(
middleware
.
TimeoutWithConfig
(
middleware
.
TimeoutConfig
{
Skipper
:
timeou
tSkipper
,
Skipper
:
grpcReques
tSkipper
,
Timeout
:
30
*
time
.
Second
,
Timeout
:
30
*
time
.
Second
,
}))
}))
...
@@ -69,8 +69,8 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
...
@@ -69,8 +69,8 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
}
}
s
.
ID
=
serverID
s
.
ID
=
serverID
if
profile
.
ServeFrontend
{
// Only serve frontend when it's enabled.
// Register frontend service.
if
profile
.
Frontend
{
frontendService
:=
frontend
.
NewFrontendService
(
profile
,
store
)
frontendService
:=
frontend
.
NewFrontendService
(
profile
,
store
)
frontendService
.
Serve
(
ctx
,
e
)
frontendService
.
Serve
(
ctx
,
e
)
}
}
...
@@ -174,15 +174,6 @@ func grpcRequestSkipper(c echo.Context) bool {
...
@@ -174,15 +174,6 @@ func grpcRequestSkipper(c echo.Context) bool {
return
strings
.
HasPrefix
(
c
.
Request
()
.
URL
.
Path
,
"/memos.api.v2."
)
return
strings
.
HasPrefix
(
c
.
Request
()
.
URL
.
Path
,
"/memos.api.v2."
)
}
}
func
timeoutSkipper
(
c
echo
.
Context
)
bool
{
if
grpcRequestSkipper
(
c
)
{
return
true
}
// Skip timeout for blob upload which is frequently timed out.
return
c
.
Request
()
.
Method
==
http
.
MethodPost
&&
c
.
Request
()
.
URL
.
Path
==
"/api/v1/resource/blob"
}
func
CORSMiddleware
()
echo
.
MiddlewareFunc
{
func
CORSMiddleware
()
echo
.
MiddlewareFunc
{
return
func
(
next
echo
.
HandlerFunc
)
echo
.
HandlerFunc
{
return
func
(
next
echo
.
HandlerFunc
)
echo
.
HandlerFunc
{
return
func
(
c
echo
.
Context
)
error
{
return
func
(
c
echo
.
Context
)
error
{
...
...
Write
Preview
Markdown
is supported
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