aboutsummaryrefslogtreecommitdiff
path: root/tests/backend_test.go
blob: cd10c8bcd2edd4603de82c4242bbce15b71005f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-FileCopyrightText: 2018 Stefan Majewsky <majewsky@gmx.net>
// SPDX-License-Identifier: Apache-2.0

package tests

import (
	"net/http"

	"go.xyrillian.de/schwift/v2"
)

type RequestCountingBackend struct {
	Inner schwift.Backend
	Count int
}

func (b *RequestCountingBackend) EndpointURL() string {
	return b.Inner.EndpointURL()
}

func (b *RequestCountingBackend) Clone(newEndpointURL string) schwift.Backend {
	return &RequestCountingBackend{Inner: b.Inner.Clone(newEndpointURL)}
}

func (b *RequestCountingBackend) Do(req *http.Request) (*http.Response, error) {
	b.Count++
	return b.Inner.Do(req)
}