-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jasmin Gacic <jasmin.gacic@gmail.com>
- Loading branch information
1 parent
56ab6ea
commit 8615747
Showing
13 changed files
with
274 additions
and
43 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
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,82 @@ | ||
/* | ||
* Kusk Gateway API | ||
* | ||
* This is the Kusk Gateway Management API | ||
* | ||
* API version: 1.0.0 | ||
* Generated by: OpenAPI Generator (https://openapi-generator.tech) | ||
*/ | ||
|
||
package openapi | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
"strings" | ||
) | ||
|
||
// CreateNewStaticRouteApiController binds http requests to an api service and writes the service results to the http response | ||
type CreateNewStaticRouteApiController struct { | ||
service CreateNewStaticRouteApiServicer | ||
errorHandler ErrorHandler | ||
} | ||
|
||
// CreateNewStaticRouteApiOption for how the controller is set up. | ||
type CreateNewStaticRouteApiOption func(*CreateNewStaticRouteApiController) | ||
|
||
// WithCreateNewStaticRouteApiErrorHandler inject ErrorHandler into controller | ||
func WithCreateNewStaticRouteApiErrorHandler(h ErrorHandler) CreateNewStaticRouteApiOption { | ||
return func(c *CreateNewStaticRouteApiController) { | ||
c.errorHandler = h | ||
} | ||
} | ||
|
||
// NewCreateNewStaticRouteApiController creates a default api controller | ||
func NewCreateNewStaticRouteApiController(s CreateNewStaticRouteApiServicer, opts ...CreateNewStaticRouteApiOption) Router { | ||
controller := &CreateNewStaticRouteApiController{ | ||
service: s, | ||
errorHandler: DefaultErrorHandler, | ||
} | ||
|
||
for _, opt := range opts { | ||
opt(controller) | ||
} | ||
|
||
return controller | ||
} | ||
|
||
// Routes returns all of the api route for the CreateNewStaticRouteApiController | ||
func (c *CreateNewStaticRouteApiController) Routes() Routes { | ||
return Routes{ | ||
{ | ||
"CreateStaticRoute", | ||
strings.ToUpper("Post"), | ||
"/staticroutes", | ||
c.CreateStaticRoute, | ||
}, | ||
} | ||
} | ||
|
||
// CreateStaticRoute - create new static route | ||
func (c *CreateNewStaticRouteApiController) CreateStaticRoute(w http.ResponseWriter, r *http.Request) { | ||
staticRouteItemParam := StaticRouteItem{} | ||
d := json.NewDecoder(r.Body) | ||
d.DisallowUnknownFields() | ||
if err := d.Decode(&staticRouteItemParam); err != nil { | ||
c.errorHandler(w, r, &ParsingError{Err: err}, nil) | ||
return | ||
} | ||
if err := AssertStaticRouteItemRequired(staticRouteItemParam); err != nil { | ||
c.errorHandler(w, r, err, nil) | ||
return | ||
} | ||
result, err := c.service.CreateStaticRoute(r.Context(), staticRouteItemParam) | ||
// If an error occurred, encode the error with the status code | ||
if err != nil { | ||
c.errorHandler(w, r, err, &result) | ||
return | ||
} | ||
// If no error, encode the body and the result code | ||
EncodeJSONResponse(result.Body, &result.Code, w) | ||
|
||
} |
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,41 @@ | ||
/* | ||
* Kusk Gateway API | ||
* | ||
* This is the Kusk Gateway Management API | ||
* | ||
* API version: 1.0.0 | ||
* Generated by: OpenAPI Generator (https://openapi-generator.tech) | ||
*/ | ||
|
||
package openapi | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"errors" | ||
) | ||
|
||
// CreateNewStaticRouteApiService is a service that implements the logic for the CreateNewStaticRouteApiServicer | ||
// This service should implement the business logic for every endpoint for the CreateNewStaticRouteApi API. | ||
// Include any external packages or services that will be required by this service. | ||
type CreateNewStaticRouteApiService struct { | ||
} | ||
|
||
// NewCreateNewStaticRouteApiService creates a default api service | ||
func NewCreateNewStaticRouteApiService() CreateNewStaticRouteApiServicer { | ||
return &CreateNewStaticRouteApiService{} | ||
} | ||
|
||
// CreateStaticRoute - create new static route | ||
func (s *CreateNewStaticRouteApiService) CreateStaticRoute(ctx context.Context, staticRouteItem StaticRouteItem) (ImplResponse, error) { | ||
// TODO - update CreateStaticRoute with the required logic for this service method. | ||
// Add api_create_new_static_route_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. | ||
|
||
//TODO: Uncomment the next line to return response Response(200, StaticRouteItem{}) or use other options such as http.Ok ... | ||
//return Response(200, StaticRouteItem{}), nil | ||
|
||
//TODO: Uncomment the next line to return response Response(400, string{}) or use other options such as http.Ok ... | ||
//return Response(400, string{}), nil | ||
|
||
return Response(http.StatusNotImplemented, nil), errors.New("CreateStaticRoute method not implemented") | ||
} |
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
Oops, something went wrong.