Skip to content

Commit

Permalink
refactor; separate jfapi and ombi into modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfee committed Nov 2, 2020
1 parent 0f4e773 commit c84ea17
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 311 deletions.
229 changes: 98 additions & 131 deletions api.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (app *appContext) getToken(gc *gin.Context) {
var status int
var err error
var user map[string]interface{}
user, status, err = app.authJf.authenticate(creds[0], creds[1])
user, status, err = app.authJf.Authenticate(creds[0], creds[1])
if status != 200 || err != nil {
if status == 401 || status == 400 {
app.info.Println("Auth denied: Invalid username/password (Jellyfin)")
Expand Down
21 changes: 21 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package common

import (
"fmt"
"log"
)

// TimeoutHandler recovers from an http timeout.
type TimeoutHandler func()

// NewTimeoutHandler returns a new Timeout handler.
func NewTimeoutHandler(name, addr string, noFail bool) TimeoutHandler {
return func() {
out := fmt.Sprintf("Failed to authenticate with %s @ %s: Timed out", name, addr)
if noFail {
log.Print(out)
} else {
log.Fatalf(out)
}
}
}
3 changes: 3 additions & 0 deletions common/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/hrfee/jfa-go/common

go 1.15
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ go 1.14

replace github.com/hrfee/jfa-go/docs => ./docs

replace github.com/hrfee/jfa-go/jfapi => ./jfapi

replace github.com/hrfee/jfa-go/common => ./common

replace github.com/hrfee/jfa-go/ombi => ./ombi

require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
Expand All @@ -17,7 +23,10 @@ require (
github.com/go-playground/validator/v10 v10.4.0 // indirect
github.com/golang/protobuf v1.4.2
github.com/google/uuid v1.1.2 // indirect
github.com/hrfee/jfa-go/common v0.0.0-00010101000000-000000000000
github.com/hrfee/jfa-go/docs v0.0.0-20200927200337-7628e5d71da8
github.com/hrfee/jfa-go/jfapi v0.0.0-00010101000000-000000000000
github.com/hrfee/jfa-go/ombi v0.0.0-00010101000000-000000000000
github.com/jordan-wright/email v4.0.1-0.20200917010138-e1c00e156980+incompatible
github.com/json-iterator/go v1.1.10 // indirect
github.com/knz/strtime v0.0.0-20200924090105-187c67f2bf5e
Expand Down
7 changes: 7 additions & 0 deletions jfapi/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/hrfee/jfa-go/jfapi

go 1.15

replace github.com/hrfee/jfa-go/common => ../common

require github.com/hrfee/jfa-go/common v0.0.0-00010101000000-000000000000

0 comments on commit c84ea17

Please sign in to comment.