Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Dec 9, 2023
1 parent 4069b54 commit 7d93b0c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 125 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/graph-gophers/dataloader/v7 v7.1.0
github.com/hypirion/go-filecache v0.0.0-20160810125507-e3e6ef6981f0
github.com/interline-io/transitland-lib v0.14.0-rc1.0.20231202005632-a9ea742322f7
github.com/interline-io/transitland-mw v0.0.0-20231209013116-a1adf6a31e93
github.com/interline-io/transitland-mw v0.0.0-20231209020231-3660286a28cd
github.com/jellydator/ttlcache/v2 v2.11.1
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.7
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ github.com/interline-io/transitland-lib v0.14.0-rc1.0.20231202005632-a9ea742322f
github.com/interline-io/transitland-lib v0.14.0-rc1.0.20231202005632-a9ea742322f7/go.mod h1:UcfuCX6DyKt/yn5GECFn3jQ6NcZEjt5XyPjf8a3tXZ4=
github.com/interline-io/transitland-mw v0.0.0-20231209013116-a1adf6a31e93 h1:qurYqyKQAGTtjNyAlGyrNGvZ9TFBcEwwo0X7Tq8XuFU=
github.com/interline-io/transitland-mw v0.0.0-20231209013116-a1adf6a31e93/go.mod h1:N+53bL3yiFx3SoDMBJtC2dkmAZNBeRHP9safiAfvykw=
github.com/interline-io/transitland-mw v0.0.0-20231209020231-3660286a28cd h1:Id8Pd4MJOto/z3Tquy3ox996iwJY9gfSG/W24jaGqGQ=
github.com/interline-io/transitland-mw v0.0.0-20231209020231-3660286a28cd/go.mod h1:N+53bL3yiFx3SoDMBJtC2dkmAZNBeRHP9safiAfvykw=
github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww=
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4=
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag=
Expand Down
123 changes: 0 additions & 123 deletions server/server.go

This file was deleted.

30 changes: 29 additions & 1 deletion server/server_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import (
"flag"
"fmt"
"os/signal"
"strconv"
"strings"
"syscall"
"time"

"net/http"
"net/http/pprof"
"net/url"
"os"

"github.com/go-chi/chi/middleware"
Expand All @@ -23,6 +25,7 @@ import (
"github.com/interline-io/transitland-lib/tl"
"github.com/interline-io/transitland-mw/auth/ancheck"
"github.com/interline-io/transitland-mw/auth/azcheck"
"github.com/interline-io/transitland-mw/lmw"
"github.com/interline-io/transitland-mw/meters"
"github.com/interline-io/transitland-mw/metrics"
"github.com/interline-io/transitland-server/config"
Expand Down Expand Up @@ -252,7 +255,7 @@ func (cmd *Command) Run() error {
}

// Add logging middleware - must be after auth
root.Use(LoggingMiddleware(cmd.LongQueryDuration))
root.Use(lmw.LoggingMiddleware(cmd.LongQueryDuration))

// Profiling
if cmd.EnableProfiler {
Expand Down Expand Up @@ -391,3 +394,28 @@ func (i *arrayFlags) Set(value string) error {
*i = append(*i, value)
return nil
}

func getRedisOpts(v string) (*redis.Options, error) {
a, err := url.Parse(v)
if err != nil {
return nil, err
}
if a.Scheme != "redis" {
return nil, errors.New("redis URL must begin with redis://")
}
port := a.Port()
if port == "" {
port = "6379"
}
addr := fmt.Sprintf("%s:%s", a.Hostname(), port)
dbNo := 0
if len(a.Path) > 0 {
var err error
f := a.Path[1:len(a.Path)]
dbNo, err = strconv.Atoi(f)
if err != nil {
return nil, err
}
}
return &redis.Options{Addr: addr, DB: dbNo}, nil
}

0 comments on commit 7d93b0c

Please sign in to comment.