Skip to content

Commit

Permalink
Merge pull request #72 from ochanoco/hotfix/many-bugs
Browse files Browse the repository at this point in the history
Hotfix/many bugs
  • Loading branch information
akakou authored Jul 3, 2024
2 parents 8e4e941 + 440add5 commit 5f245b2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
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

0 comments on commit 5f245b2

Please sign in to comment.