2022-11-26 08:28:00 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-04-21 06:49:17 +00:00
|
|
|
. "github.com/reiver/greatape/components/api/protobuf"
|
|
|
|
. "github.com/reiver/greatape/components/contracts"
|
2022-11-26 08:28:00 +00:00
|
|
|
. "github.com/xeronith/diamante/contracts/network/http"
|
|
|
|
pipeline "github.com/xeronith/diamante/network/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type getActorHandler struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetActorHandler() IHttpHandler {
|
|
|
|
return &getActorHandler{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (handler *getActorHandler) Method() string {
|
|
|
|
return http.MethodGet
|
|
|
|
}
|
|
|
|
|
|
|
|
func (handler *getActorHandler) Path() string {
|
2023-07-17 13:41:21 +00:00
|
|
|
return "/users/:username"
|
2022-11-26 08:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (handler *getActorHandler) HandlerFunc() HttpHandlerFunc {
|
|
|
|
return func(x IServerDispatcher) error {
|
|
|
|
request := &GetActorRequest{}
|
|
|
|
result := &GetActorResult{}
|
|
|
|
|
|
|
|
onRequestUnmarshalled := func(request *GetActorRequest) {
|
|
|
|
request.Username = x.Param("username")
|
|
|
|
}
|
|
|
|
|
|
|
|
return pipeline.Handle(x,
|
|
|
|
GET_ACTOR_REQUEST,
|
|
|
|
GET_ACTOR_RESULT,
|
|
|
|
request, result,
|
|
|
|
onRequestUnmarshalled,
|
2023-05-02 17:43:35 +00:00
|
|
|
nil,
|
2022-11-26 08:28:00 +00:00
|
|
|
false,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|