Skip to content

Commit

Permalink
reject requetss with no tokenized data
Browse files Browse the repository at this point in the history
  • Loading branch information
btoews committed Jul 22, 2024
1 parent 465e09d commit 80edd21
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewTokenizer(openKey string) *tokenizer {
proxy := goproxy.NewProxyHttpServer()
tkz := &tokenizer{ProxyHttpServer: proxy, priv: priv, pub: pub}

tkz.NonproxyHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
proxy.NonproxyHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "I'm not that kind of server")
})

Expand Down Expand Up @@ -156,6 +156,13 @@ func (t *tokenizer) HandleRequest(req *http.Request, ctx *goproxy.ProxyCtx) (*ht
processors = append(processors, reqProcessors...)
}

if len(processors) == 0 {
pud.reqLog.Warn("no processors")
return nil, errorResponse(ErrBadRequest)
}

pud.reqLog = pud.reqLog.WithField("processors", len(processors))

for _, processor := range processors {
if err := processor(req); err != nil {
pud.reqLog.WithError(err).Warn("run processor")
Expand Down

0 comments on commit 80edd21

Please sign in to comment.