...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package server
16
17 import (
18 "time"
19
20 "github.com/go-openapi/loads"
21 "github.com/sigstore/timestamp-authority/pkg/api"
22 "github.com/sigstore/timestamp-authority/pkg/generated/restapi"
23 "github.com/sigstore/timestamp-authority/pkg/generated/restapi/operations"
24 "github.com/sigstore/timestamp-authority/pkg/internal/cmdparams"
25 )
26
27
28 func NewRestAPIServer(host string,
29 port int,
30 scheme []string,
31 httpReadOnly bool,
32 readTimeout, writeTimeout time.Duration) *restapi.Server {
33 doc, _ := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
34 server := restapi.NewServer(operations.NewTimestampServerAPI(doc))
35
36 server.Host = host
37 server.Port = port
38 server.EnabledListeners = scheme
39 server.ReadTimeout = readTimeout
40 server.WriteTimeout = writeTimeout
41 cmdparams.IsHTTPPingOnly = httpReadOnly
42 api.ConfigureAPI()
43 server.ConfigureAPI()
44
45 return server
46 }
47
View as plain text