-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package endpoint | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-kit/kit/endpoint" | ||
"github.com/vterdunov/janna-api/internal/service" | ||
) | ||
|
||
// MakeOpenAPIEndpoint returns an endpoint via the passed service | ||
func MakeOpenAPIEndpoint(s service.Service) endpoint.Endpoint { | ||
return func(ctx context.Context, request interface{}) (interface{}, error) { | ||
spec, err := s.OpenAPI(ctx) | ||
if err != nil { | ||
return OpenAPIResponse{Spec: nil, Err: err}, err | ||
} | ||
|
||
return OpenAPIResponse{Spec: spec}, nil | ||
} | ||
} | ||
|
||
// OpenAPIResponse serves OpenAPI specification | ||
type OpenAPIResponse struct { | ||
Spec []byte | ||
Err error `json:"error,omitempty"` | ||
} | ||
|
||
// Failed implements Failer | ||
func (r OpenAPIResponse) Failed() error { | ||
return r.Err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters