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

#3 add GOA generated DSL code

parent c43aca38
No related branches found
No related tags found
1 merge request!3Create SET cache endpoint
......@@ -28,13 +28,13 @@ func NewClient(get, set goa.Endpoint) *Client {
}
// Get calls the "Get" endpoint of the "cache" service.
func (c *Client) Get(ctx context.Context, p *CacheGetRequest) (res []byte, err error) {
func (c *Client) Get(ctx context.Context, p *CacheGetRequest) (res interface{}, err error) {
var ires interface{}
ires, err = c.GetEndpoint(ctx, p)
if err != nil {
return
}
return ires.([]byte), nil
return ires.(interface{}), nil
}
// Set calls the "Set" endpoint of the "cache" service.
......
......@@ -13,11 +13,9 @@ import (
// Cache service allows storing and retrieving data from distributed cache.
type Service interface {
// Get value from the cache. The result is a sequence of bytes which the client
// must decode.
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.
// Get JSON value from the cache.
Get(context.Context, *CacheGetRequest) (res interface{}, err error)
// Set a JSON value in the cache.
Set(context.Context, *CacheSetRequest) (err error)
}
......
......@@ -77,7 +77,7 @@ func DecodeGetResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody
switch resp.StatusCode {
case http.StatusOK:
var (
body []byte
body interface{}
err error
)
err = decoder(resp).Decode(&body)
......
......@@ -20,7 +20,7 @@ import (
// endpoint.
func EncodeGetResponse(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 {
res, _ := v.([]byte)
res, _ := v.(interface{})
enc := encoder(ctx, w)
body := res
w.WriteHeader(http.StatusOK)
......
......@@ -217,8 +217,8 @@ Usage:
%[1]s [globalflags] cache COMMAND [flags]
COMMAND:
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.
get: Get JSON value from the cache.
set: Set a JSON value in the cache.
Additional help:
%[1]s cache COMMAND --help
......@@ -227,7 +227,7 @@ Additional help:
func cacheGetUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] cache get -key STRING -namespace STRING -scope STRING
Get value from the cache. The result is a sequence of bytes which the client must decode.
Get JSON value from the cache.
-key STRING:
-namespace STRING:
-scope STRING:
......@@ -240,7 +240,7 @@ Example:
func cacheSetUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] cache set -body JSON -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.
Set a JSON value in the cache.
-body JSON:
-key STRING:
-namespace STRING:
......
{"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":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}}}}
\ No newline at end of file
{"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 JSON value from the cache.","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":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","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":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}}}}
\ No newline at end of file
......@@ -40,8 +40,7 @@ paths:
tags:
- cache
summary: Get cache
description: Get value from the cache. The result is a sequence of bytes which
the client must decode.
description: Get JSON value from the cache.
operationId: cache#Get
parameters:
- name: x-cache-key
......@@ -64,15 +63,14 @@ paths:
description: OK response.
schema:
type: string
format: byte
format: binary
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.
description: Set a JSON value in the cache.
operationId: cache#Set
parameters:
- name: x-cache-key
......
{"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":"Et illum fugiat ut.","format":"binary"},"example":"Optio aliquam error nam."}}},"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
{"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 JSON value from the cache.","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":"Qui iusto enim est dolores dolorem et.","format":"binary"},"example":"Quisquam ab dolores distinctio quis."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","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":"Et illum fugiat ut.","format":"binary"},"example":"Optio aliquam error nam."}}},"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
......@@ -30,8 +30,7 @@ paths:
tags:
- cache
summary: Get cache
description: Get value from the cache. The result is a sequence of bytes which
the client must decode.
description: Get JSON value from the cache.
operationId: cache#Get
parameters:
- name: x-cache-key
......@@ -71,89 +70,14 @@ paths:
application/json:
schema:
type: string
example:
- 81
- 117
- 105
- 32
- 105
- 117
- 115
- 116
- 111
- 32
- 101
- 110
- 105
- 109
- 32
- 101
- 115
- 116
- 32
- 100
- 111
- 108
- 111
- 114
- 101
- 115
- 32
- 100
- 111
- 108
- 111
- 114
- 101
- 109
- 32
- 101
- 116
- 46
example: Qui iusto enim est dolores dolorem et.
format: binary
example:
- 81
- 117
- 105
- 115
- 113
- 117
- 97
- 109
- 32
- 97
- 98
- 32
- 100
- 111
- 108
- 111
- 114
- 101
- 115
- 32
- 100
- 105
- 115
- 116
- 105
- 110
- 99
- 116
- 105
- 111
- 32
- 113
- 117
- 105
- 115
- 46
example: Quisquam ab dolores distinctio quis.
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.
description: Set a JSON value in the cache.
operationId: cache#Set
parameters:
- name: x-cache-key
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment