read secret key from config.json
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"api": {
|
"api": {
|
||||||
|
"secret": "CHANGE_YOUR_SECRET_HERE",
|
||||||
"database_name": "music.sqlite3",
|
"database_name": "music.sqlite3",
|
||||||
"single_thread": true,
|
"single_thread": true,
|
||||||
"addr": ":8080",
|
"addr": ":8080",
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
"msw-open-music/pkg/database"
|
|
||||||
"msw-open-music/pkg/commonconfig"
|
"msw-open-music/pkg/commonconfig"
|
||||||
|
"msw-open-music/pkg/database"
|
||||||
"msw-open-music/pkg/tmpfs"
|
"msw-open-music/pkg/tmpfs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
@@ -29,7 +28,7 @@ func NewAPI(config commonconfig.Config) (*API, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
store := sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))
|
store := sessions.NewCookieStore([]byte(config.APIConfig.SECRET))
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
apiMux := http.NewServeMux()
|
apiMux := http.NewServeMux()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type APIConfig struct {
|
|||||||
Addr string `json:"addr"`
|
Addr string `json:"addr"`
|
||||||
FfmpegThreads int64 `json:"ffmpeg_threads"`
|
FfmpegThreads int64 `json:"ffmpeg_threads"`
|
||||||
FfmpegConfigList []FfmpegConfig `json:"ffmpeg_config_list"`
|
FfmpegConfigList []FfmpegConfig `json:"ffmpeg_config_list"`
|
||||||
|
SECRET string `json:"secret"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FfmpegConfigList struct {
|
type FfmpegConfigList struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user