Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/many bugs #72

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var DB_CONFIG = utils.ReadEnv("TORIMA_DB_CONFIG", "file:./data/db.sqlite3?_fk=1"
var SECRET = utils.ReadEnv("TORIMA_SECRET", utils.RandomString(32))

var CONFIG_FILE = "./config.yaml"
var STATIC_FOLDER = "./static"

var CLIENT_ID = utils.ReadEnvOrPanic("TORIMA_CLIENT_ID")
var CLIENT_SECRET = utils.ReadEnvOrPanic("TORIMA_CLIENT_SECRET")
2 changes: 1 addition & 1 deletion extension/directors/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func AuthDirector(c *core.TorimaDirectorPackageContext) (core.TorimaPackageStatu
return core.NoAuthNeeded, nil
}

err = utils.MakeError(err, "failed to authenticate: ")
err = utils.MakeError(err, utils.UnauthorizedErrorTag)
return core.ForceStop, err
}

Expand Down
3 changes: 2 additions & 1 deletion extension/modify_resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"strconv"
"strings"

"github.com/PuerkitoBio/goquery"
"github.com/ochanoco/torima/core"
Expand Down Expand Up @@ -44,7 +45,7 @@ func InjectHTML(html string, c *core.TorimaModifyResponsePackageContext) (core.T
func InjectServiceWorkerModifyResponse(c *core.TorimaModifyResponsePackageContext) (core.TorimaPackageStatus, error) {
contentType := c.Target.Header.Get("Content-Type")

if contentType != "text/html; charset=utf-8" {
if !strings.HasPrefix(contentType, "text/html") {
return core.Keep, nil
}

Expand Down
4 changes: 3 additions & 1 deletion extension/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package extension

import (
"fmt"
"net/http"

"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"github.com/ochanoco/ninsho"
gin_ninsho "github.com/ochanoco/ninsho/extension/gin"
"github.com/ochanoco/torima/core"
"github.com/ochanoco/torima/static"
)

func StaticWeb(proxy *core.TorimaProxy, r *gin.RouterGroup) {
Expand All @@ -17,7 +19,7 @@ func StaticWeb(proxy *core.TorimaProxy, r *gin.RouterGroup) {
}
}())

r.Static("/static", core.STATIC_FOLDER)
r.StaticFS("/static", http.FS(static.Static))
}

func ConfigWeb(proxy *core.TorimaProxy, r *gin.RouterGroup) {
Expand Down
6 changes: 6 additions & 0 deletions static/static.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package static

import "embed"

//go:embed sw/*.js wrapper/*.js
var Static embed.FS
4 changes: 0 additions & 4 deletions utils/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ var errorStatusMap = map[string]int{
}

func MakeError(e error, tag string) error {
if e == nil {
return nil
}

return fmt.Errorf("%s: %v", tag, e)
}

Expand Down
Loading