Skip to content
Snippets Groups Projects
Commit 5251adf9 authored by Yordan Kinkov's avatar Yordan Kinkov
Browse files

#3 add GOA dsl for cache set endpoint

parent b041945f
Branches
Tags
1 merge request!3Create SET cache endpoint
Showing with 483 additions and 65 deletions
...@@ -16,12 +16,14 @@ import ( ...@@ -16,12 +16,14 @@ import (
// Client is the "cache" service client. // Client is the "cache" service client.
type Client struct { type Client struct {
GetEndpoint goa.Endpoint GetEndpoint goa.Endpoint
SetEndpoint goa.Endpoint
} }
// NewClient initializes a "cache" service client given the endpoints. // NewClient initializes a "cache" service client given the endpoints.
func NewClient(get goa.Endpoint) *Client { func NewClient(get, set goa.Endpoint) *Client {
return &Client{ return &Client{
GetEndpoint: get, GetEndpoint: get,
SetEndpoint: set,
} }
} }
...@@ -34,3 +36,9 @@ func (c *Client) Get(ctx context.Context, p *CacheGetRequest) (res []byte, err e ...@@ -34,3 +36,9 @@ func (c *Client) Get(ctx context.Context, p *CacheGetRequest) (res []byte, err e
} }
return ires.([]byte), nil return ires.([]byte), nil
} }
// Set calls the "Set" endpoint of the "cache" service.
func (c *Client) Set(ctx context.Context, p *CacheSetRequest) (err error) {
_, err = c.SetEndpoint(ctx, p)
return
}
...@@ -16,18 +16,21 @@ import ( ...@@ -16,18 +16,21 @@ import (
// Endpoints wraps the "cache" service endpoints. // Endpoints wraps the "cache" service endpoints.
type Endpoints struct { type Endpoints struct {
Get goa.Endpoint Get goa.Endpoint
Set goa.Endpoint
} }
// NewEndpoints wraps the methods of the "cache" service with endpoints. // NewEndpoints wraps the methods of the "cache" service with endpoints.
func NewEndpoints(s Service) *Endpoints { func NewEndpoints(s Service) *Endpoints {
return &Endpoints{ return &Endpoints{
Get: NewGetEndpoint(s), Get: NewGetEndpoint(s),
Set: NewSetEndpoint(s),
} }
} }
// Use applies the given middleware to all the "cache" service endpoints. // Use applies the given middleware to all the "cache" service endpoints.
func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) {
e.Get = m(e.Get) e.Get = m(e.Get)
e.Set = m(e.Set)
} }
// NewGetEndpoint returns an endpoint function that calls the method "Get" of // NewGetEndpoint returns an endpoint function that calls the method "Get" of
...@@ -38,3 +41,12 @@ func NewGetEndpoint(s Service) goa.Endpoint { ...@@ -38,3 +41,12 @@ func NewGetEndpoint(s Service) goa.Endpoint {
return s.Get(ctx, p) return s.Get(ctx, p)
} }
} }
// NewSetEndpoint returns an endpoint function that calls the method "Set" of
// service "cache".
func NewSetEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req interface{}) (interface{}, error) {
p := req.(*CacheSetRequest)
return nil, s.Set(ctx, p)
}
}
...@@ -16,6 +16,9 @@ type Service interface { ...@@ -16,6 +16,9 @@ type Service interface {
// Get value from the cache. The result is a sequence of bytes which the client // Get value from the cache. The result is a sequence of bytes which the client
// must decode. // must decode.
Get(context.Context, *CacheGetRequest) (res []byte, err error) Get(context.Context, *CacheGetRequest) (res []byte, err error)
// Set value in the cache. The HTTP request body is stored as value and the key
// is assembled from HTTP request headers.
Set(context.Context, *CacheSetRequest) (err error)
} }
// ServiceName is the name of the service as defined in the design. This is the // ServiceName is the name of the service as defined in the design. This is the
...@@ -26,7 +29,7 @@ const ServiceName = "cache" ...@@ -26,7 +29,7 @@ const ServiceName = "cache"
// MethodNames lists the service method names as defined in the design. These // MethodNames lists the service method names as defined in the design. These
// are the same values that are set in the endpoint request contexts under the // are the same values that are set in the endpoint request contexts under the
// MethodKey key. // MethodKey key.
var MethodNames = [1]string{"Get"} var MethodNames = [2]string{"Get", "Set"}
// CacheGetRequest is the payload type of the cache service Get method. // CacheGetRequest is the payload type of the cache service Get method.
type CacheGetRequest struct { type CacheGetRequest struct {
...@@ -34,3 +37,11 @@ type CacheGetRequest struct { ...@@ -34,3 +37,11 @@ type CacheGetRequest struct {
Namespace string Namespace string
Scope string Scope string
} }
// CacheSetRequest is the payload type of the cache service Set method.
type CacheSetRequest struct {
Data []byte
Key string
Namespace string
Scope string
}
...@@ -32,3 +32,32 @@ func BuildGetPayload(cacheGetKey string, cacheGetNamespace string, cacheGetScope ...@@ -32,3 +32,32 @@ func BuildGetPayload(cacheGetKey string, cacheGetNamespace string, cacheGetScope
return v, nil return v, nil
} }
// BuildSetPayload builds the payload for the cache Set endpoint from CLI flags.
func BuildSetPayload(cacheSetBody string, cacheSetKey string, cacheSetNamespace string, cacheSetScope string) (*cache.CacheSetRequest, error) {
var body []byte
{
body = []byte(cacheSetBody)
}
var key string
{
key = cacheSetKey
}
var namespace string
{
namespace = cacheSetNamespace
}
var scope string
{
scope = cacheSetScope
}
v := body
res := &cache.CacheSetRequest{
Data: v,
}
res.Key = key
res.Namespace = namespace
res.Scope = scope
return res, nil
}
...@@ -20,6 +20,9 @@ type Client struct { ...@@ -20,6 +20,9 @@ type Client struct {
// Get Doer is the HTTP client used to make requests to the Get endpoint. // Get Doer is the HTTP client used to make requests to the Get endpoint.
GetDoer goahttp.Doer GetDoer goahttp.Doer
// Set Doer is the HTTP client used to make requests to the Set endpoint.
SetDoer goahttp.Doer
// RestoreResponseBody controls whether the response bodies are reset after // RestoreResponseBody controls whether the response bodies are reset after
// decoding so they can be read again. // decoding so they can be read again.
RestoreResponseBody bool RestoreResponseBody bool
...@@ -41,6 +44,7 @@ func NewClient( ...@@ -41,6 +44,7 @@ func NewClient(
) *Client { ) *Client {
return &Client{ return &Client{
GetDoer: doer, GetDoer: doer,
SetDoer: doer,
RestoreResponseBody: restoreBody, RestoreResponseBody: restoreBody,
scheme: scheme, scheme: scheme,
host: host, host: host,
...@@ -72,3 +76,27 @@ func (c *Client) Get() goa.Endpoint { ...@@ -72,3 +76,27 @@ func (c *Client) Get() goa.Endpoint {
return decodeResponse(resp) return decodeResponse(resp)
} }
} }
// Set returns an endpoint that makes HTTP requests to the cache service Set
// server.
func (c *Client) Set() goa.Endpoint {
var (
encodeRequest = EncodeSetRequest(c.encoder)
decodeResponse = DecodeSetResponse(c.decoder, c.RestoreResponseBody)
)
return func(ctx context.Context, v interface{}) (interface{}, error) {
req, err := c.BuildSetRequest(ctx, v)
if err != nil {
return nil, err
}
err = encodeRequest(req, v)
if err != nil {
return nil, err
}
resp, err := c.SetDoer.Do(req)
if err != nil {
return nil, goahttp.ErrRequestError("cache", "Set", err)
}
return decodeResponse(resp)
}
}
...@@ -91,3 +91,73 @@ func DecodeGetResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody ...@@ -91,3 +91,73 @@ func DecodeGetResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody
} }
} }
} }
// BuildSetRequest instantiates a HTTP request object with method and path set
// to call the "cache" service "Set" endpoint
func (c *Client) BuildSetRequest(ctx context.Context, v interface{}) (*http.Request, error) {
u := &url.URL{Scheme: c.scheme, Host: c.host, Path: SetCachePath()}
req, err := http.NewRequest("POST", u.String(), nil)
if err != nil {
return nil, goahttp.ErrInvalidURL("cache", "Set", u.String(), err)
}
if ctx != nil {
req = req.WithContext(ctx)
}
return req, nil
}
// EncodeSetRequest returns an encoder for requests sent to the cache Set
// server.
func EncodeSetRequest(encoder func(*http.Request) goahttp.Encoder) func(*http.Request, interface{}) error {
return func(req *http.Request, v interface{}) error {
p, ok := v.(*cache.CacheSetRequest)
if !ok {
return goahttp.ErrInvalidType("cache", "Set", "*cache.CacheSetRequest", v)
}
{
head := p.Key
req.Header.Set("x-cache-key", head)
}
{
head := p.Namespace
req.Header.Set("x-cache-namespace", head)
}
{
head := p.Scope
req.Header.Set("x-cache-scope", head)
}
body := p.Data
if err := encoder(req).Encode(&body); err != nil {
return goahttp.ErrEncodingError("cache", "Set", err)
}
return nil
}
}
// DecodeSetResponse returns a decoder for responses returned by the cache Set
// endpoint. restoreBody controls whether the response body should be restored
// after having been read.
func DecodeSetResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (interface{}, error) {
return func(resp *http.Response) (interface{}, error) {
if restoreBody {
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
resp.Body = ioutil.NopCloser(bytes.NewBuffer(b))
defer func() {
resp.Body = ioutil.NopCloser(bytes.NewBuffer(b))
}()
} else {
defer resp.Body.Close()
}
switch resp.StatusCode {
case http.StatusCreated:
return nil, nil
default:
body, _ := ioutil.ReadAll(resp.Body)
return nil, goahttp.ErrInvalidResponse("cache", "Set", resp.StatusCode, string(body))
}
}
}
...@@ -11,3 +11,8 @@ package client ...@@ -11,3 +11,8 @@ package client
func GetCachePath() string { func GetCachePath() string {
return "/v1/cache" return "/v1/cache"
} }
// SetCachePath returns the URL path to the cache service Set HTTP endpoint.
func SetCachePath() string {
return "/v1/cache"
}
...@@ -9,6 +9,7 @@ package server ...@@ -9,6 +9,7 @@ package server
import ( import (
"context" "context"
"io"
"net/http" "net/http"
goahttp "goa.design/goa/v3/http" goahttp "goa.design/goa/v3/http"
...@@ -57,3 +58,54 @@ func DecodeGetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Dec ...@@ -57,3 +58,54 @@ func DecodeGetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Dec
return payload, nil return payload, nil
} }
} }
// EncodeSetResponse returns an encoder for responses returned by the cache Set
// endpoint.
func EncodeSetResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error {
return func(ctx context.Context, w http.ResponseWriter, v interface{}) error {
w.WriteHeader(http.StatusCreated)
return nil
}
}
// DecodeSetRequest returns a decoder for requests sent to the cache Set
// endpoint.
func DecodeSetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error) {
return func(r *http.Request) (interface{}, error) {
var (
body []byte
err error
)
err = decoder(r).Decode(&body)
if err != nil {
if err == io.EOF {
return nil, goa.MissingPayloadError()
}
return nil, goa.DecodePayloadError(err.Error())
}
var (
key string
namespace string
scope string
)
key = r.Header.Get("x-cache-key")
if key == "" {
err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-key", "header"))
}
namespace = r.Header.Get("x-cache-namespace")
if namespace == "" {
err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-namespace", "header"))
}
scope = r.Header.Get("x-cache-scope")
if scope == "" {
err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-scope", "header"))
}
if err != nil {
return nil, err
}
payload := NewSetCacheSetRequest(body, key, namespace, scope)
return payload, nil
}
}
...@@ -11,3 +11,8 @@ package server ...@@ -11,3 +11,8 @@ package server
func GetCachePath() string { func GetCachePath() string {
return "/v1/cache" return "/v1/cache"
} }
// SetCachePath returns the URL path to the cache service Set HTTP endpoint.
func SetCachePath() string {
return "/v1/cache"
}
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
type Server struct { type Server struct {
Mounts []*MountPoint Mounts []*MountPoint
Get http.Handler Get http.Handler
Set http.Handler
} }
// ErrorNamer is an interface implemented by generated error structs that // ErrorNamer is an interface implemented by generated error structs that
...@@ -56,8 +57,10 @@ func New( ...@@ -56,8 +57,10 @@ func New(
return &Server{ return &Server{
Mounts: []*MountPoint{ Mounts: []*MountPoint{
{"Get", "GET", "/v1/cache"}, {"Get", "GET", "/v1/cache"},
{"Set", "POST", "/v1/cache"},
}, },
Get: NewGetHandler(e.Get, mux, decoder, encoder, errhandler, formatter), Get: NewGetHandler(e.Get, mux, decoder, encoder, errhandler, formatter),
Set: NewSetHandler(e.Set, mux, decoder, encoder, errhandler, formatter),
} }
} }
...@@ -67,11 +70,13 @@ func (s *Server) Service() string { return "cache" } ...@@ -67,11 +70,13 @@ func (s *Server) Service() string { return "cache" }
// Use wraps the server handlers with the given middleware. // Use wraps the server handlers with the given middleware.
func (s *Server) Use(m func(http.Handler) http.Handler) { func (s *Server) Use(m func(http.Handler) http.Handler) {
s.Get = m(s.Get) s.Get = m(s.Get)
s.Set = m(s.Set)
} }
// Mount configures the mux to serve the cache endpoints. // Mount configures the mux to serve the cache endpoints.
func Mount(mux goahttp.Muxer, h *Server) { func Mount(mux goahttp.Muxer, h *Server) {
MountGetHandler(mux, h.Get) MountGetHandler(mux, h.Get)
MountSetHandler(mux, h.Set)
} }
// Mount configures the mux to serve the cache endpoints. // Mount configures the mux to serve the cache endpoints.
...@@ -129,3 +134,54 @@ func NewGetHandler( ...@@ -129,3 +134,54 @@ func NewGetHandler(
} }
}) })
} }
// MountSetHandler configures the mux to serve the "cache" service "Set"
// endpoint.
func MountSetHandler(mux goahttp.Muxer, h http.Handler) {
f, ok := h.(http.HandlerFunc)
if !ok {
f = func(w http.ResponseWriter, r *http.Request) {
h.ServeHTTP(w, r)
}
}
mux.Handle("POST", "/v1/cache", f)
}
// NewSetHandler creates a HTTP handler which loads the HTTP request and calls
// the "cache" service "Set" endpoint.
func NewSetHandler(
endpoint goa.Endpoint,
mux goahttp.Muxer,
decoder func(*http.Request) goahttp.Decoder,
encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
errhandler func(context.Context, http.ResponseWriter, error),
formatter func(err error) goahttp.Statuser,
) http.Handler {
var (
decodeRequest = DecodeSetRequest(mux, decoder)
encodeResponse = EncodeSetResponse(encoder)
encodeError = goahttp.ErrorEncoder(encoder, formatter)
)
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValue(r.Context(), goahttp.AcceptTypeKey, r.Header.Get("Accept"))
ctx = context.WithValue(ctx, goa.MethodKey, "Set")
ctx = context.WithValue(ctx, goa.ServiceKey, "cache")
payload, err := decodeRequest(r)
if err != nil {
if err := encodeError(ctx, w, err); err != nil {
errhandler(ctx, w, err)
}
return
}
res, err := endpoint(ctx, payload)
if err != nil {
if err := encodeError(ctx, w, err); err != nil {
errhandler(ctx, w, err)
}
return
}
if err := encodeResponse(ctx, w, res); err != nil {
errhandler(ctx, w, err)
}
})
}
...@@ -20,3 +20,16 @@ func NewGetCacheGetRequest(key string, namespace string, scope string) *cache.Ca ...@@ -20,3 +20,16 @@ func NewGetCacheGetRequest(key string, namespace string, scope string) *cache.Ca
return v return v
} }
// NewSetCacheSetRequest builds a cache service Set endpoint payload.
func NewSetCacheSetRequest(body []byte, key string, namespace string, scope string) *cache.CacheSetRequest {
v := body
res := &cache.CacheSetRequest{
Data: v,
}
res.Key = key
res.Namespace = namespace
res.Scope = scope
return res
}
...@@ -25,14 +25,14 @@ import ( ...@@ -25,14 +25,14 @@ import (
// //
func UsageCommands() string { func UsageCommands() string {
return `health (liveness|readiness) return `health (liveness|readiness)
cache get cache (get|set)
` `
} }
// UsageExamples produces an example of a valid invocation of the CLI tool. // UsageExamples produces an example of a valid invocation of the CLI tool.
func UsageExamples() string { func UsageExamples() string {
return os.Args[0] + ` health liveness` + "\n" + return os.Args[0] + ` health liveness` + "\n" +
os.Args[0] + ` cache get --key "Officiis fuga architecto cum." --namespace "Sint adipisci." --scope "Debitis id reprehenderit incidunt necessitatibus assumenda."` + "\n" + os.Args[0] + ` cache get --key "Suscipit sed consequatur rerum occaecati in veritatis." --namespace "Repudiandae eos consequatur sint dolorum occaecati." --scope "Voluptatum modi tenetur tempore quia est ratione."` + "\n" +
"" ""
} }
...@@ -58,6 +58,12 @@ func ParseEndpoint( ...@@ -58,6 +58,12 @@ func ParseEndpoint(
cacheGetKeyFlag = cacheGetFlags.String("key", "REQUIRED", "") cacheGetKeyFlag = cacheGetFlags.String("key", "REQUIRED", "")
cacheGetNamespaceFlag = cacheGetFlags.String("namespace", "REQUIRED", "") cacheGetNamespaceFlag = cacheGetFlags.String("namespace", "REQUIRED", "")
cacheGetScopeFlag = cacheGetFlags.String("scope", "REQUIRED", "") cacheGetScopeFlag = cacheGetFlags.String("scope", "REQUIRED", "")
cacheSetFlags = flag.NewFlagSet("set", flag.ExitOnError)
cacheSetBodyFlag = cacheSetFlags.String("body", "REQUIRED", "")
cacheSetKeyFlag = cacheSetFlags.String("key", "REQUIRED", "")
cacheSetNamespaceFlag = cacheSetFlags.String("namespace", "REQUIRED", "")
cacheSetScopeFlag = cacheSetFlags.String("scope", "REQUIRED", "")
) )
healthFlags.Usage = healthUsage healthFlags.Usage = healthUsage
healthLivenessFlags.Usage = healthLivenessUsage healthLivenessFlags.Usage = healthLivenessUsage
...@@ -65,6 +71,7 @@ func ParseEndpoint( ...@@ -65,6 +71,7 @@ func ParseEndpoint(
cacheFlags.Usage = cacheUsage cacheFlags.Usage = cacheUsage
cacheGetFlags.Usage = cacheGetUsage cacheGetFlags.Usage = cacheGetUsage
cacheSetFlags.Usage = cacheSetUsage
if err := flag.CommandLine.Parse(os.Args[1:]); err != nil { if err := flag.CommandLine.Parse(os.Args[1:]); err != nil {
return nil, nil, err return nil, nil, err
...@@ -115,6 +122,9 @@ func ParseEndpoint( ...@@ -115,6 +122,9 @@ func ParseEndpoint(
case "get": case "get":
epf = cacheGetFlags epf = cacheGetFlags
case "set":
epf = cacheSetFlags
} }
} }
...@@ -153,6 +163,9 @@ func ParseEndpoint( ...@@ -153,6 +163,9 @@ func ParseEndpoint(
case "get": case "get":
endpoint = c.Get() endpoint = c.Get()
data, err = cachec.BuildGetPayload(*cacheGetKeyFlag, *cacheGetNamespaceFlag, *cacheGetScopeFlag) data, err = cachec.BuildGetPayload(*cacheGetKeyFlag, *cacheGetNamespaceFlag, *cacheGetScopeFlag)
case "set":
endpoint = c.Set()
data, err = cachec.BuildSetPayload(*cacheSetBodyFlag, *cacheSetKeyFlag, *cacheSetNamespaceFlag, *cacheSetScopeFlag)
} }
} }
} }
...@@ -205,6 +218,7 @@ Usage: ...@@ -205,6 +218,7 @@ Usage:
COMMAND: COMMAND:
get: Get value from the cache. The result is a sequence of bytes which the client must decode. get: Get value from the cache. The result is a sequence of bytes which the client must decode.
set: Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.
Additional help: Additional help:
%[1]s cache COMMAND --help %[1]s cache COMMAND --help
...@@ -219,6 +233,20 @@ Get value from the cache. The result is a sequence of bytes which the client mus ...@@ -219,6 +233,20 @@ Get value from the cache. The result is a sequence of bytes which the client mus
-scope STRING: -scope STRING:
Example: Example:
%[1]s cache get --key "Officiis fuga architecto cum." --namespace "Sint adipisci." --scope "Debitis id reprehenderit incidunt necessitatibus assumenda." %[1]s cache get --key "Suscipit sed consequatur rerum occaecati in veritatis." --namespace "Repudiandae eos consequatur sint dolorum occaecati." --scope "Voluptatum modi tenetur tempore quia est ratione."
`, os.Args[0])
}
func cacheSetUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] cache set -body STRING -key STRING -namespace STRING -scope STRING
Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.
-body STRING:
-key STRING:
-namespace STRING:
-scope STRING:
Example:
%[1]s cache set --body "UXVhc2kgdXQu" --key "Quasi perspiciatis." --namespace "Accusantium animi non alias." --scope "Esse inventore ullam placeat aut."
`, os.Args[0]) `, os.Args[0])
} }
{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"byte"}}},"schemes":["http"]}}}} {"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"byte"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"},{"name":"bytes","in":"body","required":true,"schema":{"type":"string","format":"byte"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}}}}
\ No newline at end of file \ No newline at end of file
...@@ -67,3 +67,37 @@ paths: ...@@ -67,3 +67,37 @@ paths:
format: byte format: byte
schemes: schemes:
- http - http
post:
tags:
- cache
summary: Set cache
description: Set value in the cache. The HTTP request body is stored as value
and the key is assembled from HTTP request headers.
operationId: cache#Set
parameters:
- name: x-cache-key
in: header
description: Cache entry key
required: true
type: string
- name: x-cache-namespace
in: header
description: Cache entry namespace
required: true
type: string
- name: x-cache-scope
in: header
description: Cache entry scope
required: true
type: string
- name: bytes
in: body
required: true
schema:
type: string
format: byte
responses:
"201":
description: Created response.
schemes:
- http
{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"UmVwdWRpYW5kYWUgZW9zIGNvbnNlcXVhdHVyIHNpbnQgZG9sb3J1bSBvY2NhZWNhdGku","format":"binary"},"example":"Vm9sdXB0YXR1bSBtb2RpIHRlbmV0dXIgdGVtcG9yZSBxdWlhIGVzdCByYXRpb25lLg=="}}}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]} {"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"UXVpIGl1c3RvIGVuaW0gZXN0IGRvbG9yZXMgZG9sb3JlbSBldC4=","format":"binary"},"example":"UXVpc3F1YW0gYWIgZG9sb3JlcyBkaXN0aW5jdGlvIHF1aXMu"}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"RXQgaWxsdW0gZnVnaWF0IHV0Lg==","format":"binary"},"example":"T3B0aW8gYWxpcXVhbSBlcnJvciBuYW0u"}}},"responses":{"201":{"description":"Created response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]}
\ No newline at end of file \ No newline at end of file
...@@ -72,108 +72,175 @@ paths: ...@@ -72,108 +72,175 @@ paths:
schema: schema:
type: string type: string
example: example:
- 82 - 81
- 101
- 112
- 117 - 117
- 100
- 105 - 105
- 97
- 110
- 100
- 97
- 101
- 32 - 32
- 101 - 105
- 111 - 117
- 115 - 115
- 32 - 116
- 99
- 111 - 111
- 32
- 101
- 110 - 110
- 115 - 105
- 109
- 32
- 101 - 101
- 113 - 115
- 117
- 97
- 116 - 116
- 117
- 114
- 32 - 32
- 100
- 111
- 108
- 111
- 114
- 101
- 115 - 115
- 105
- 110
- 116
- 32 - 32
- 100 - 100
- 111 - 111
- 108 - 108
- 111 - 111
- 114 - 114
- 117 - 101
- 109 - 109
- 32 - 32
- 111
- 99
- 99
- 97
- 101 - 101
- 99
- 97
- 116 - 116
- 105
- 46 - 46
format: binary format: binary
example: example:
- 86 - 81
- 111
- 108
- 117 - 117
- 112 - 105
- 116 - 115
- 97 - 113
- 116
- 117 - 117
- 97
- 109 - 109
- 32 - 32
- 109 - 97
- 98
- 32
- 100
- 111 - 111
- 108
- 111
- 114
- 101
- 115
- 32
- 100 - 100
- 105 - 105
- 32 - 115
- 116 - 116
- 101 - 105
- 110 - 110
- 101 - 99
- 116
- 117
- 114
- 32
- 116 - 116
- 101 - 105
- 109
- 112
- 111 - 111
- 114
- 101
- 32 - 32
- 113 - 113
- 117 - 117
- 105 - 105
- 97
- 32
- 101
- 115 - 115
- 46
post:
tags:
- cache
summary: Set cache
description: Set value in the cache. The HTTP request body is stored as value
and the key is assembled from HTTP request headers.
operationId: cache#Set
parameters:
- name: x-cache-key
in: header
description: Cache entry key
allowEmptyValue: true
required: true
schema:
type: string
description: Cache entry key
example: did:web:example.com
example: did:web:example.com
- name: x-cache-namespace
in: header
description: Cache entry namespace
allowEmptyValue: true
required: true
schema:
type: string
description: Cache entry namespace
example: Login
example: Login
- name: x-cache-scope
in: header
description: Cache entry scope
allowEmptyValue: true
required: true
schema:
type: string
description: Cache entry scope
example: administration
example: administration
requestBody:
required: true
content:
application/json:
schema:
type: string
example:
- 69
- 116 - 116
- 32 - 32
- 114 - 105
- 108
- 108
- 117
- 109
- 32
- 102
- 117
- 103
- 105
- 97 - 97
- 116 - 116
- 105 - 32
- 111 - 117
- 110 - 116
- 101
- 46 - 46
format: binary
example:
- 79
- 112
- 116
- 105
- 111
- 32
- 97
- 108
- 105
- 113
- 117
- 97
- 109
- 32
- 101
- 114
- 114
- 111
- 114
- 32
- 110
- 97
- 109
- 46
responses:
"201":
description: Created response.
components: {} components: {}
tags: tags:
- name: health - name: health
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment