|  | // Copyright 2017 Google Inc. | 
|  | // | 
|  | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | // you may not use this file except in compliance with the License. | 
|  | // You may obtain a copy of the License at | 
|  | // | 
|  | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | // | 
|  | // Unless required by applicable law or agreed to in writing, software | 
|  | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | // See the License for the specific language governing permissions and | 
|  | // limitations under the License. | 
|  |  | 
|  | package apidVerifyApiKey | 
|  |  | 
|  | import ( | 
|  | "github.com/30x/apid-core" | 
|  | "github.com/apigee-labs/transicator/common" | 
|  | ) | 
|  |  | 
|  | type handler struct { | 
|  | } | 
|  |  | 
|  | func (h *handler) String() string { | 
|  | return "verifyAPIKey" | 
|  | } | 
|  |  | 
|  | func (h *handler) Handle(e apid.Event) { | 
|  |  | 
|  | snapData, ok := e.(*common.Snapshot) | 
|  | if ok { | 
|  | processSnapshot(snapData) | 
|  | } | 
|  | return | 
|  | } | 
|  |  | 
|  | func processSnapshot(snapshot *common.Snapshot) { | 
|  |  | 
|  | log.Debugf("Snapshot received. Switching to DB version: %s", snapshot.SnapshotInfo) | 
|  |  | 
|  | db, err := data.DBVersion(snapshot.SnapshotInfo) | 
|  | if err != nil { | 
|  | log.Panicf("Unable to access database: %v", err) | 
|  | } | 
|  |  | 
|  | setDB(db) | 
|  | return | 
|  | } |