Skip to content
Snippets Groups Projects
Commit c43aca38 authored by Lyuben Penkovski's avatar Lyuben Penkovski Committed by Yordan Kinkov
Browse files

Apply 4 suggestion(s) to 3 file(s)

parent d2125545
No related branches found
No related tags found
1 merge request!3Create SET cache endpoint
Pipeline #49803 passed
...@@ -12,9 +12,9 @@ flowchart LR ...@@ -12,9 +12,9 @@ flowchart LR
### API Documentation ### API Documentation
The API Documentation is accessible at `/swagger-ui` path in OAS 3.0 format. The API Documentation is accessible at `/swagger-ui` path in OAS 3.0 format.
Example: `localhost:8080/swagger-ui` Example: `http://localhost:8080/swagger-ui`
### Prerequisites ### Dependencies
There must be a running instance of [Redis](https://redis.io/) visible to the service. There must be a running instance of [Redis](https://redis.io/) visible to the service.
The address, username and password of the Redis in-memory store instance must be provided as environment variables. The address, username and password of the Redis in-memory store instance must be provided as environment variables.
......
...@@ -64,7 +64,7 @@ var _ = Service("cache", func() { ...@@ -64,7 +64,7 @@ var _ = Service("cache", func() {
}) })
Method("Set", func() { Method("Set", func() {
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.")
Payload(CacheSetRequest) Payload(CacheSetRequest)
Result(Empty) Result(Empty)
......
...@@ -53,7 +53,7 @@ func (s *Service) Get(ctx context.Context, req *cache.CacheGetRequest) ([]byte, ...@@ -53,7 +53,7 @@ func (s *Service) Get(ctx context.Context, req *cache.CacheGetRequest) ([]byte,
func (s *Service) Set(ctx context.Context, req *cache.CacheSetRequest) error { func (s *Service) Set(ctx context.Context, req *cache.CacheSetRequest) error {
var operation = zap.String("operation", "set") var operation = zap.String("operation", "set")
if req.Key == "" || req.Namespace == "" || req.Scope == "" || len(req.Data.(map[string]interface{})) == 0 { if req.Key == "" || req.Namespace == "" || req.Scope == "" {
s.logger.Error("bad request: missing key or namespace or scope or data", operation) s.logger.Error("bad request: missing key or namespace or scope or data", operation)
return errors.New(errors.BadRequest, "bad request") return errors.New(errors.BadRequest, "bad request")
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment