my god...it's finally done
This commit is contained in:
parent
2baf71214e
commit
19d76ebc47
43 changed files with 1008 additions and 550 deletions
19
main.go
19
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -8,11 +9,11 @@ import (
|
|||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"arimelody.me/arimelody.me/admin"
|
||||
"arimelody.me/arimelody.me/api"
|
||||
"arimelody.me/arimelody.me/global"
|
||||
musicView "arimelody.me/arimelody.me/music/view"
|
||||
"arimelody.me/arimelody.me/templates"
|
||||
"arimelody-web/admin"
|
||||
"arimelody-web/api"
|
||||
"arimelody-web/global"
|
||||
musicView "arimelody-web/music/view"
|
||||
"arimelody-web/templates"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq"
|
||||
|
@ -22,8 +23,11 @@ const DEFAULT_PORT int = 8080
|
|||
|
||||
func main() {
|
||||
// initialise database connection
|
||||
var dbHost = os.Getenv("ARIMELODY_DB_HOST")
|
||||
if dbHost == "" { dbHost = "127.0.0.1" }
|
||||
|
||||
var err error
|
||||
global.DB, err = sqlx.Connect("postgres", "user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
|
||||
global.DB, err = sqlx.Connect("postgres", "host=" + dbHost + " user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "FATAL: Unable to create database connection pool: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
@ -64,9 +68,10 @@ func createServeMux() *http.ServeMux {
|
|||
func staticHandler(directory string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
info, err := os.Stat(filepath.Join(directory, filepath.Clean(r.URL.Path)))
|
||||
|
||||
// does the file exist?
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue