Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Remilia Scarlet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reviath
Remilia Scarlet
Commits
07cf1efd
Commit
07cf1efd
authored
May 18, 2021
by
Reviath
Browse files
Options
Downloads
Patches
Plain Diff
Getting web port and base url separately
parent
965ae1c6
No related branches found
No related tags found
No related merge requests found
Pipeline
#682
passed
May 18, 2021
Stage: build
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
config.json
+2
-1
2 additions, 1 deletion
config.json
config/config.go
+6
-3
6 additions, 3 deletions
config/config.go
main.go
+1
-1
1 addition, 1 deletion
main.go
web/web.go
+4
-4
4 additions, 4 deletions
web/web.go
with
13 additions
and
9 deletions
config.json
+
2
−
1
View file @
07cf1efd
...
...
@@ -8,6 +8,7 @@
"User"
:
"USER"
,
"Password"
:
"PASSWORD"
,
"Host"
:
"HOST"
,
"WebURL"
:
"WEB_URL"
,
"WebPort"
:
"WEB_PORT"
,
"BaseURL"
:
"BASE_URL"
,
"ClientSecret"
:
"CLIENT_SECRET"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
config/config.go
+
6
−
3
View file @
07cf1efd
...
...
@@ -17,7 +17,8 @@ var (
config
*
configStruct
// config structure
Password
string
// Password to connect MySQL database
Host
string
// Host to connect MySQL database
WebURL
string
// WebURL to run website
WebPort
string
// WebPort to run website at
BaseURL
string
// BaseURL to run website at
ClientSecret
string
// ClientSecret for OAuth2
)
...
...
@@ -31,7 +32,8 @@ type configStruct struct {
Host
string
`json:"Host"`
// Host from config file
User
string
`json:"User"`
// User from config file
Password
string
`json:"Password"`
// Password from config file
WebURL
string
`json:"WebURL"`
// WebURL from config file
WebPort
string
`json:"WebPort"`
// WebURL from config file
BaseURL
string
`json:"BaseURL"`
// BaseURL from config file
ClientSecret
string
`json:"ClientSecret"`
// ClientSecret from config file
}
...
...
@@ -60,7 +62,8 @@ func ReadConfig() error {
User
=
config
.
User
Password
=
config
.
Password
LoadInteractions
=
config
.
LoadInteractions
WebURL
=
config
.
WebURL
WebPort
=
config
.
WebPort
BaseURL
=
config
.
BaseURL
ClientSecret
=
config
.
ClientSecret
return
nil
...
...
This diff is collapsed.
Click to expand it.
main.go
+
1
−
1
View file @
07cf1efd
...
...
@@ -15,7 +15,7 @@ import (
func
main
()
{
config
.
ReadConfig
()
if
config
.
Token
==
"TOKEN"
||
config
.
ClientSecret
==
"CLIENT_SECRET"
||
config
.
WebURL
==
"
WEB
_URL"
{
if
config
.
Token
==
"TOKEN"
||
config
.
ClientSecret
==
"CLIENT_SECRET"
||
config
.
Web
Port
==
"WEB_PORT"
||
config
.
Base
URL
==
"
BASE
_URL"
{
fmt
.
Println
(
"Edit config file before running."
)
os
.
Exit
(
1
)
}
...
...
This diff is collapsed.
Click to expand it.
web/web.go
+
4
−
4
View file @
07cf1efd
...
...
@@ -29,7 +29,7 @@ func Listen(session *discordgo.Session) {
cli
:=
GetClientUser
(
session
)
conf
:=
&
oauth2
.
Config
{
RedirectURL
:
fmt
.
Sprintf
(
"%s/callback"
,
config
.
WebURL
),
RedirectURL
:
fmt
.
Sprintf
(
"%s
:%s
/callback"
,
config
.
BaseURL
,
config
.
WebPort
),
ClientID
:
cli
.
ID
,
ClientSecret
:
config
.
ClientSecret
,
Scopes
:
[]
string
{
discord
.
ScopeIdentify
,
discord
.
ScopeGuilds
},
...
...
@@ -206,10 +206,10 @@ func Listen(session *discordgo.Session) {
}
})
fmt
.
Printf
(
"Attempting to run website at
\"
%s
\"
\n
"
,
config
.
WebURL
)
fmt
.
Printf
(
"Attempting to run website at
\"
%s
:%s
\"
\n
"
,
config
.
BaseURL
,
config
.
WebPort
)
time
.
Sleep
(
1
*
time
.
Second
)
if
err
:=
server
.
Run
(
config
.
Web
URL
[
7
:
]
);
err
!=
nil
{
fmt
.
Printf
(
"Cannot run website at
\"
%s
\"
, running on http://localhost:8000.
\n
"
,
config
.
WebURL
)
if
err
:=
server
.
Run
(
":"
+
config
.
Web
Port
);
err
!=
nil
{
fmt
.
Printf
(
"Cannot run website at
\"
%s
:%s
\"
, running on http://localhost:8000.
\n
"
,
config
.
BaseURL
,
config
.
WebPort
)
server
.
Run
(
":8000"
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment