Skip to content

Commit

Permalink
Renamed some files for a more cohesive structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Jul 9, 2014
1 parent 0e7036d commit cf063ed
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 105 deletions.
7 changes: 6 additions & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,12 @@ func securityHandler(handler func(http.ResponseWriter, *http.Request)) func(http
if tykAuthKey != config.Secret {
// Error
log.Warning("Attempted administrative access with invalid or missing key!")
handle_error(w, r, "Authorisation failed", 403, ApiSpec{})

responseMessage := createError("Method not supported")
w.WriteHeader(403)
fmt.Fprintf(w, string(responseMessage))

return
} else {
handler(w, r)
}
Expand Down
File renamed without changes.
File renamed without changes.
102 changes: 0 additions & 102 deletions gateway.go

This file was deleted.

File renamed without changes.
25 changes: 25 additions & 0 deletions handler_proxy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (

"net/http"
"net/http/httputil"

)

type ApiError struct {
Message string
}

// Proxies request onwards
func ProxyHandler(p *httputil.ReverseProxy, apiSpec ApiSpec) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {

tm := TykMiddleware{apiSpec, p}
handler := SuccessHandler{tm}
// Skip all other execution
handler.ServeHTTP(w, r)
return

}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ func loadApps(ApiSpecs []ApiSpec, Muxer *http.ServeMux) {
log.Info(remote)
proxy := httputil.NewSingleHostReverseProxy(remote)

myHandler := http.HandlerFunc(handler(proxy, spec))
proxyHandler := http.HandlerFunc(ProxyHandler(proxy, spec))
tykMiddleware := TykMiddleware{spec, proxy}

chain := alice.New(
VersionCheck{tykMiddleware}.New(),
KeyExists{tykMiddleware}.New(),
KeyExpired{tykMiddleware}.New(),
AccessRightsCheck{tykMiddleware}.New(),
RateLimitAndQuotaCheck{tykMiddleware}.New()).Then(myHandler)
RateLimitAndQuotaCheck{tykMiddleware}.New()).Then(proxyHandler)
Muxer.Handle(spec.Proxy.ListenPath, chain)
}
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit cf063ed

Please sign in to comment.