kopia lustrzana https://github.com/reiver/greatape
46 wiersze
988 B
Go
46 wiersze
988 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
. "github.com/reiver/greatape/components/api/protobuf"
|
|
. "github.com/reiver/greatape/components/contracts"
|
|
. "github.com/xeronith/diamante/contracts/network/http"
|
|
pipeline "github.com/xeronith/diamante/network/http"
|
|
)
|
|
|
|
type postToInboxHandler struct {
|
|
}
|
|
|
|
func PostToInboxHandler() IHttpHandler {
|
|
return &postToInboxHandler{}
|
|
}
|
|
|
|
func (handler *postToInboxHandler) Method() string {
|
|
return http.MethodPost
|
|
}
|
|
|
|
func (handler *postToInboxHandler) Path() string {
|
|
return "/u/:username/inbox"
|
|
}
|
|
|
|
func (handler *postToInboxHandler) HandlerFunc() HttpHandlerFunc {
|
|
return func(x IServerDispatcher) error {
|
|
request := &PostToInboxRequest{}
|
|
result := &PostToInboxResult{}
|
|
|
|
onRequestUnmarshalled := func(request *PostToInboxRequest) {
|
|
request.Username = x.Param("username")
|
|
}
|
|
|
|
return pipeline.Handle(x,
|
|
"post_to_inbox",
|
|
POST_TO_INBOX_REQUEST,
|
|
POST_TO_INBOX_RESULT,
|
|
request, result,
|
|
onRequestUnmarshalled,
|
|
false,
|
|
)
|
|
}
|
|
}
|