parent
5080b43a04
commit
baf425453d
2 changed files with 17 additions and 12 deletions
6
app.go
6
app.go
|
@ -199,10 +199,7 @@ func (a *app) Serve(ctx context.Context) {
|
||||||
}()
|
}()
|
||||||
edts := a.cfg.GetBool(cfgUploaderHeaderEnableDefaultTimestamp)
|
edts := a.cfg.GetBool(cfgUploaderHeaderEnableDefaultTimestamp)
|
||||||
uploader := uploader.New(a.log, a.pool, edts)
|
uploader := uploader.New(a.log, a.pool, edts)
|
||||||
downloader, err := downloader.New(a.log, downloader.Settings{ZipCompression: a.cfg.GetBool(cfgZipCompression)}, a.pool)
|
downloader := downloader.New(a.log, downloader.Settings{ZipCompression: a.cfg.GetBool(cfgZipCompression)}, a.pool)
|
||||||
if err != nil {
|
|
||||||
a.log.Fatal("failed to create downloader", zap.Error(err))
|
|
||||||
}
|
|
||||||
// Configure router.
|
// Configure router.
|
||||||
r := router.New()
|
r := router.New()
|
||||||
r.RedirectTrailingSlash = true
|
r.RedirectTrailingSlash = true
|
||||||
|
@ -237,6 +234,7 @@ func (a *app) Serve(ctx context.Context) {
|
||||||
tlsKeyPath := a.cfg.GetString(cfgTLSKey)
|
tlsKeyPath := a.cfg.GetString(cfgTLSKey)
|
||||||
|
|
||||||
a.webServer.Handler = r.Handler
|
a.webServer.Handler = r.Handler
|
||||||
|
var err error
|
||||||
if tlsCertPath == "" && tlsKeyPath == "" {
|
if tlsCertPath == "" && tlsKeyPath == "" {
|
||||||
a.log.Info("running web server", zap.String("address", bind))
|
a.log.Info("running web server", zap.String("address", bind))
|
||||||
err = a.webServer.ListenAndServe(bind)
|
err = a.webServer.ListenAndServe(bind)
|
||||||
|
|
|
@ -13,6 +13,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-http-gw/response"
|
"github.com/nspcc-dev/neofs-http-gw/response"
|
||||||
"github.com/nspcc-dev/neofs-http-gw/tokens"
|
"github.com/nspcc-dev/neofs-http-gw/tokens"
|
||||||
|
@ -190,7 +192,7 @@ func systemBackwardTranslator(key string) string {
|
||||||
|
|
||||||
strs := strings.Split(key, "_")
|
strs := strings.Split(key, "_")
|
||||||
for i, s := range strs {
|
for i, s := range strs {
|
||||||
s = strings.Title(strings.ToLower(s))
|
s = title(strings.ToLower(s))
|
||||||
res.WriteString(s)
|
res.WriteString(s)
|
||||||
if i != len(strs)-1 {
|
if i != len(strs)-1 {
|
||||||
res.WriteString("-")
|
res.WriteString("-")
|
||||||
|
@ -200,6 +202,16 @@ func systemBackwardTranslator(key string) string {
|
||||||
return res.String()
|
return res.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func title(str string) string {
|
||||||
|
if str == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
r, size := utf8.DecodeRuneInString(str)
|
||||||
|
r0 := unicode.ToTitle(r)
|
||||||
|
return string(r0) + str[size:]
|
||||||
|
}
|
||||||
|
|
||||||
func bearerToken(ctx context.Context) *token.BearerToken {
|
func bearerToken(ctx context.Context) *token.BearerToken {
|
||||||
if tkn, err := tokens.LoadBearerToken(ctx); err == nil {
|
if tkn, err := tokens.LoadBearerToken(ctx); err == nil {
|
||||||
return tkn
|
return tkn
|
||||||
|
@ -243,13 +255,8 @@ type Settings struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates an instance of Downloader using specified options.
|
// New creates an instance of Downloader using specified options.
|
||||||
func New(log *zap.Logger, settings Settings, conns *pool.Pool) (*Downloader, error) {
|
func New(log *zap.Logger, settings Settings, conns *pool.Pool) *Downloader {
|
||||||
var err error
|
return &Downloader{log: log, pool: conns, settings: settings}
|
||||||
d := &Downloader{log: log, pool: conns, settings: settings}
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to get neofs client's reusable artifacts: %w", err)
|
|
||||||
}
|
|
||||||
return d, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Downloader) newRequest(ctx *fasthttp.RequestCtx, log *zap.Logger) *request {
|
func (d *Downloader) newRequest(ctx *fasthttp.RequestCtx, log *zap.Logger) *request {
|
||||||
|
|
Loading…
Reference in a new issue