Skip to content

Commit

Permalink
Merge pull request google#657 from vmarmol/events
Browse files Browse the repository at this point in the history
Handle container names in resource path
  • Loading branch information
rjnagal committed Apr 20, 2015
2 parents 44848b9 + ed6dd78 commit 99aa5c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 0 additions & 4 deletions api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,6 @@ func getEventRequest(r *http.Request) (*events.Request, bool, error) {
query.EndTime = newTime
}
}
if val, ok := urlMap["container_name"]; ok {
containerName := strings.Trim(val[0], " /")
query.ContainerName = "/" + containerName
}

return query, stream, nil
}
Expand Down
8 changes: 5 additions & 3 deletions api/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package api
import (
"fmt"
"net/http"
"path"
"strconv"

"github.com/golang/glog"
Expand Down Expand Up @@ -261,17 +262,18 @@ func (self *version1_3) SupportedRequestTypes() []string {
func (self *version1_3) HandleRequest(requestType string, request []string, m manager.Manager, w http.ResponseWriter, r *http.Request) error {
switch requestType {
case eventsApi:
return handleEventRequest(m, w, r)
return handleEventRequest(request, m, w, r)
default:
return self.baseVersion.HandleRequest(requestType, request, m, w, r)
}
}

func handleEventRequest(m manager.Manager, w http.ResponseWriter, r *http.Request) error {
func handleEventRequest(request []string, m manager.Manager, w http.ResponseWriter, r *http.Request) error {
query, stream, err := getEventRequest(r)
if err != nil {
return err
}
query.ContainerName = path.Join("/", getContainerName(request))
glog.V(4).Infof("Api - Events(%v)", query)
if !stream {
pastEvents, err := m.GetPastEvents(query)
Expand Down Expand Up @@ -388,7 +390,7 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
}
return writeResult(fi, w)
case eventsApi:
return handleEventRequest(m, w, r)
return handleEventRequest(request, m, w, r)
default:
return fmt.Errorf("unknown request type %q", requestType)
}
Expand Down

0 comments on commit 99aa5c5

Please sign in to comment.