import sources from develop/0.1.0
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package responses
|
||||
|
||||
// Response is the Ping Response
|
||||
type Response struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type ComicList struct {
|
||||
Comics []Comic `json:"comics"`
|
||||
}
|
||||
|
||||
type Comic struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"gitlab.com/tpeetz-kontor/kontor-go/cmd/pkg/context/comic/responses"
|
||||
"gitlab.com/tpeetz-kontor/kontor-go/cmd/pkg/infrastructure/app"
|
||||
responseFactory "gitlab.com/tpeetz-kontor/kontor-go/cmd/pkg/infrastructure/response"
|
||||
)
|
||||
|
||||
// Handler is the http.Handler for this request
|
||||
type Handler struct {
|
||||
app *app.Application
|
||||
}
|
||||
|
||||
// NewHandler will create a new Handler to handle this request
|
||||
func NewHandler(app *app.Application) *Handler {
|
||||
return &Handler{app}
|
||||
}
|
||||
|
||||
// Handle will handle the incoming request
|
||||
func (handler *Handler) ComicList(response http.ResponseWriter, request *http.Request) {
|
||||
handler.app.Logger.Info("Ping Handler Dispatched.")
|
||||
|
||||
responseFactory.Send(
|
||||
response,
|
||||
http.StatusOK,
|
||||
&responses.ComicList{
|
||||
Comics: []responses.Comic{{ID: "123", Title: "Comic1"}, {ID: "123", Title: "Comic1"}},
|
||||
},
|
||||
handler.app.Config.HTTP.Content,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user