Skip to content

Commit

Permalink
rename pkg/control to pkg/servicecontrol
Browse files Browse the repository at this point in the history
  • Loading branch information
timburks committed Oct 13, 2023
1 parent 5f92f64 commit 0b12af5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/zero/cmd/petstore/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package petstore
import (
"net/http"

"github.com/apigee/registry-experimental/cmd/zero/pkg/control"
"github.com/apigee/registry-experimental/cmd/zero/pkg/servicecontrol"
"github.com/gin-gonic/gin"
"github.com/spf13/cobra"
)
Expand All @@ -28,7 +28,7 @@ func serveCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
router := gin.Default()
router.Use(control.ServiceControl(args[0]))
router.Use(servicecontrol.Middleware(args[0]))
router.GET("/v1/pets", GetPets)
router.GET("/v1/pets/:id", GetPetById)
router.POST("/v1/pets", CreatePet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package control
package servicecontrol

import (
"context"
Expand All @@ -31,7 +31,7 @@ import (
"google.golang.org/api/servicecontrol/v1"
)

func ServiceControl(serviceName string) func(c *gin.Context) {
func Middleware(serviceName string) func(c *gin.Context) {
return func(c *gin.Context) {
t, err := NewTracker(c, serviceName)
if err != nil {
Expand Down Expand Up @@ -172,6 +172,7 @@ func (t *Tracker) CallHandler() {
t.Context.Next()
t.BackendDuration = time.Since(start)
}

func (t *Tracker) Report() error {
status := t.Context.Writer.Status()
now := time.Now()
Expand Down

0 comments on commit 0b12af5

Please sign in to comment.