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
e3fac742
Commit
e3fac742
authored
Aug 18, 2022
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update logger
parent
ce390f3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
14 deletions
+9
-14
root.go
bin/server/cmd/root.go
+6
-13
server.go
server/server.go
+3
-1
No files found.
bin/server/cmd/root.go
View file @
e3fac742
...
...
@@ -22,34 +22,27 @@ const (
`
)
type
Main
struct
{
profile
*
profile
.
Profile
}
func
(
m
*
Main
)
Run
()
error
{
func
Run
(
profile
*
profile
.
Profile
)
error
{
ctx
:=
context
.
Background
()
db
:=
DB
.
NewDB
(
m
.
profile
)
db
:=
DB
.
NewDB
(
profile
)
if
err
:=
db
.
Open
(
ctx
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot open db: %w"
,
err
)
}
s
:=
server
.
NewServer
(
m
.
profile
)
s
:=
server
.
NewServer
(
profile
)
storeInstance
:=
store
.
New
(
db
.
Db
,
m
.
profile
)
storeInstance
:=
store
.
New
(
db
.
Db
,
profile
)
s
.
Store
=
storeInstance
println
(
greetingBanner
)
fmt
.
Printf
(
"Version %s has started at :%d
\n
"
,
m
.
profile
.
Version
,
m
.
profile
.
Port
)
fmt
.
Printf
(
"Version %s has started at :%d
\n
"
,
profile
.
Version
,
profile
.
Port
)
return
s
.
Run
()
}
func
Execute
()
{
profile
:=
profile
.
GetProfile
()
m
:=
Main
{
profile
:
profile
,
}
println
(
"---"
)
println
(
"profile"
)
...
...
@@ -59,7 +52,7 @@ func Execute() {
println
(
"version:"
,
profile
.
Version
)
println
(
"---"
)
if
err
:=
m
.
Run
(
);
err
!=
nil
{
if
err
:=
Run
(
profile
);
err
!=
nil
{
fmt
.
Printf
(
"error: %+v
\n
"
,
err
)
os
.
Exit
(
1
)
}
...
...
server/server.go
View file @
e3fac742
...
...
@@ -29,7 +29,9 @@ func NewServer(profile *profile.Profile) *Server {
e
.
HidePort
=
true
e
.
Use
(
middleware
.
LoggerWithConfig
(
middleware
.
LoggerConfig
{
Format
:
"${method} ${uri} ${status}
\n
"
,
Format
:
`{"time":"${time_rfc3339}",`
+
`"method":"${method}","uri":"${uri}",`
+
`"status":${status},"error":"${error}"}`
+
"
\n
"
,
}))
e
.
Use
(
middleware
.
CORS
())
...
...
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