Documentation ¶
Index ¶
- Variables
- func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter(routers ...Router) *mux.Router
- func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)
- func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)
- type Error
- type ImplResponse
- type Item
- type ItemsApiController
- func (c *ItemsApiController) CreateItem(w http.ResponseWriter, r *http.Request)
- func (c *ItemsApiController) DeleteItem(w http.ResponseWriter, r *http.Request)
- func (c *ItemsApiController) GetItem(w http.ResponseWriter, r *http.Request)
- func (c *ItemsApiController) GetItems(w http.ResponseWriter, r *http.Request)
- func (c *ItemsApiController) Routes() Routes
- func (c *ItemsApiController) UpdateItem(w http.ResponseWriter, r *http.Request)
- type ItemsApiRouter
- type ItemsApiService
- func (s *ItemsApiService) CreateItem(ctx context.Context, item Item) (ImplResponse, error)
- func (s *ItemsApiService) DeleteItem(ctx context.Context, id string) (ImplResponse, error)
- func (s *ItemsApiService) GetItem(ctx context.Context, id string) (ImplResponse, error)
- func (s *ItemsApiService) GetItems(ctx context.Context, languageId string) (ImplResponse, error)
- func (s *ItemsApiService) UpdateItem(ctx context.Context, id string, item Item) (ImplResponse, error)
- type ItemsApiServicer
- type Language
- type LanguagesApiController
- func (c *LanguagesApiController) CreateLanguage(w http.ResponseWriter, r *http.Request)
- func (c *LanguagesApiController) DeleteLanguage(w http.ResponseWriter, r *http.Request)
- func (c *LanguagesApiController) GetLanguage(w http.ResponseWriter, r *http.Request)
- func (c *LanguagesApiController) GetLanguages(w http.ResponseWriter, r *http.Request)
- func (c *LanguagesApiController) Routes() Routes
- func (c *LanguagesApiController) UpdateLanguage(w http.ResponseWriter, r *http.Request)
- type LanguagesApiRouter
- type LanguagesApiService
- func (s *LanguagesApiService) CreateLanguage(ctx context.Context, language Language) (ImplResponse, error)
- func (s *LanguagesApiService) DeleteLanguage(ctx context.Context, id string) (ImplResponse, error)
- func (s *LanguagesApiService) GetLanguage(ctx context.Context, id string) (ImplResponse, error)
- func (s *LanguagesApiService) GetLanguages(ctx context.Context) (ImplResponse, error)
- func (s *LanguagesApiService) UpdateLanguage(ctx context.Context, id string, language Language) (ImplResponse, error)
- type LanguagesApiServicer
- type Route
- type Router
- type Routes
Constants ¶
This section is empty.
Variables ¶
var StubItem = Item{
Id: "a619249d-8d5a-4b40-8b1f-ba4da2f8199b",
LanguageId: "20f329ac-123f-48f0-917d-a70497cfd22a",
LanguageName: "Esperanto",
Value: "Saluton mondo",
}
StubItem is a sample item for this simple implementation
var StubLanguage = Language{
Id: "20f329ac-123f-48f0-917d-a70497cfd22a",
Name: "Esperanto",
Description: "Esperanto is a constructed auxiliary language. Its creator was L. L. Zamenhof, a Polish eye doctor.",
}
StubLanguage is a sample language for this example
Functions ¶
func EncodeJSONResponse ¶
func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
func ReadFormFileToTempFile ¶
ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file
Types ¶
type ImplResponse ¶
type ImplResponse struct { Code int Body interface{} }
Implementation response defines an error code with the associated body
func Response ¶
func Response(code int, body interface{}) ImplResponse
Response return a ImplResponse struct filled
type ItemsApiController ¶
type ItemsApiController struct {
// contains filtered or unexported fields
}
A ItemsApiController binds http requests to an api service and writes the service results to the http response
func (*ItemsApiController) CreateItem ¶
func (c *ItemsApiController) CreateItem(w http.ResponseWriter, r *http.Request)
CreateItem - Creates a new Hello World item.
func (*ItemsApiController) DeleteItem ¶
func (c *ItemsApiController) DeleteItem(w http.ResponseWriter, r *http.Request)
DeleteItem - Deletes a Hello World item.
func (*ItemsApiController) GetItem ¶
func (c *ItemsApiController) GetItem(w http.ResponseWriter, r *http.Request)
GetItem - Returns a Hello World item.
func (*ItemsApiController) GetItems ¶
func (c *ItemsApiController) GetItems(w http.ResponseWriter, r *http.Request)
GetItems - Returns a list of Hello World items.
func (*ItemsApiController) Routes ¶
func (c *ItemsApiController) Routes() Routes
Routes returns all of the api route for the ItemsApiController
func (*ItemsApiController) UpdateItem ¶
func (c *ItemsApiController) UpdateItem(w http.ResponseWriter, r *http.Request)
UpdateItem - Updates a Hello World item.
type ItemsApiRouter ¶
type ItemsApiRouter interface { CreateItem(http.ResponseWriter, *http.Request) DeleteItem(http.ResponseWriter, *http.Request) GetItem(http.ResponseWriter, *http.Request) GetItems(http.ResponseWriter, *http.Request) UpdateItem(http.ResponseWriter, *http.Request) }
ItemsApiRouter defines the required methods for binding the api requests to a responses for the ItemsApi The ItemsApiRouter implementation should parse necessary information from the http request, pass the data to a ItemsApiServicer to perform the required actions, then write the service results to the http response.
type ItemsApiService ¶
type ItemsApiService struct { }
ItemsApiService is a service that implents the logic for the ItemsApiServicer This service should implement the business logic for every endpoint for the ItemsApi API. Include any external packages or services that will be required by this service.
func (*ItemsApiService) CreateItem ¶
func (s *ItemsApiService) CreateItem(ctx context.Context, item Item) (ImplResponse, error)
CreateItem - Creates a new Hello World item.
func (*ItemsApiService) DeleteItem ¶
func (s *ItemsApiService) DeleteItem(ctx context.Context, id string) (ImplResponse, error)
DeleteItem - Deletes a Hello World item.
func (*ItemsApiService) GetItem ¶
func (s *ItemsApiService) GetItem(ctx context.Context, id string) (ImplResponse, error)
GetItem - Returns a Hello World item.
func (*ItemsApiService) GetItems ¶
func (s *ItemsApiService) GetItems(ctx context.Context, languageId string) (ImplResponse, error)
GetItems - Returns a list of Hello World items.
func (*ItemsApiService) UpdateItem ¶
func (s *ItemsApiService) UpdateItem(ctx context.Context, id string, item Item) (ImplResponse, error)
UpdateItem - Updates a Hello World item.
type ItemsApiServicer ¶
type ItemsApiServicer interface { CreateItem(context.Context, Item) (ImplResponse, error) DeleteItem(context.Context, string) (ImplResponse, error) GetItem(context.Context, string) (ImplResponse, error) GetItems(context.Context, string) (ImplResponse, error) UpdateItem(context.Context, string, Item) (ImplResponse, error) }
ItemsApiServicer defines the api actions for the ItemsApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
func NewItemsApiService ¶
func NewItemsApiService() ItemsApiServicer
NewItemsApiService creates a default api service
type LanguagesApiController ¶
type LanguagesApiController struct {
// contains filtered or unexported fields
}
A LanguagesApiController binds http requests to an api service and writes the service results to the http response
func (*LanguagesApiController) CreateLanguage ¶
func (c *LanguagesApiController) CreateLanguage(w http.ResponseWriter, r *http.Request)
CreateLanguage - Creates a new langauge.
func (*LanguagesApiController) DeleteLanguage ¶
func (c *LanguagesApiController) DeleteLanguage(w http.ResponseWriter, r *http.Request)
DeleteLanguage - Deletes a langauge.
func (*LanguagesApiController) GetLanguage ¶
func (c *LanguagesApiController) GetLanguage(w http.ResponseWriter, r *http.Request)
GetLanguage - Returns a language.
func (*LanguagesApiController) GetLanguages ¶
func (c *LanguagesApiController) GetLanguages(w http.ResponseWriter, r *http.Request)
GetLanguages - Returns a list of languages.
func (*LanguagesApiController) Routes ¶
func (c *LanguagesApiController) Routes() Routes
Routes returns all of the api route for the LanguagesApiController
func (*LanguagesApiController) UpdateLanguage ¶
func (c *LanguagesApiController) UpdateLanguage(w http.ResponseWriter, r *http.Request)
UpdateLanguage - Updates a langauge.
type LanguagesApiRouter ¶
type LanguagesApiRouter interface { CreateLanguage(http.ResponseWriter, *http.Request) DeleteLanguage(http.ResponseWriter, *http.Request) GetLanguage(http.ResponseWriter, *http.Request) GetLanguages(http.ResponseWriter, *http.Request) UpdateLanguage(http.ResponseWriter, *http.Request) }
LanguagesApiRouter defines the required methods for binding the api requests to a responses for the LanguagesApi The LanguagesApiRouter implementation should parse necessary information from the http request, pass the data to a LanguagesApiServicer to perform the required actions, then write the service results to the http response.
type LanguagesApiService ¶
type LanguagesApiService struct { }
LanguagesApiService is a service that implents the logic for the LanguagesApiServicer This service should implement the business logic for every endpoint for the LanguagesApi API. Include any external packages or services that will be required by this service.
func (*LanguagesApiService) CreateLanguage ¶
func (s *LanguagesApiService) CreateLanguage(ctx context.Context, language Language) (ImplResponse, error)
CreateLanguage - Creates a new langauge.
func (*LanguagesApiService) DeleteLanguage ¶
func (s *LanguagesApiService) DeleteLanguage(ctx context.Context, id string) (ImplResponse, error)
DeleteLanguage - Deletes a langauge.
func (*LanguagesApiService) GetLanguage ¶
func (s *LanguagesApiService) GetLanguage(ctx context.Context, id string) (ImplResponse, error)
GetLanguage - Returns a language.
func (*LanguagesApiService) GetLanguages ¶
func (s *LanguagesApiService) GetLanguages(ctx context.Context) (ImplResponse, error)
GetLanguages - Returns a list of languages.
func (*LanguagesApiService) UpdateLanguage ¶
func (s *LanguagesApiService) UpdateLanguage(ctx context.Context, id string, language Language) (ImplResponse, error)
UpdateLanguage - Updates a langauge.
type LanguagesApiServicer ¶
type LanguagesApiServicer interface { CreateLanguage(context.Context, Language) (ImplResponse, error) DeleteLanguage(context.Context, string) (ImplResponse, error) GetLanguage(context.Context, string) (ImplResponse, error) GetLanguages(context.Context) (ImplResponse, error) UpdateLanguage(context.Context, string, Language) (ImplResponse, error) }
LanguagesApiServicer defines the api actions for the LanguagesApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
func NewLanguagesApiService ¶
func NewLanguagesApiService() LanguagesApiServicer
NewLanguagesApiService creates a default api service
type Route ¶
type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc }
A Route defines the parameters for an api endpoint
type Router ¶
type Router interface {
Routes() Routes
}
Router defines the required methods for retrieving api routes
func NewItemsApiController ¶
func NewItemsApiController(s ItemsApiServicer) Router
NewItemsApiController creates a default api controller
func NewLanguagesApiController ¶
func NewLanguagesApiController(s LanguagesApiServicer) Router
NewLanguagesApiController creates a default api controller