Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Enable various HTTP methods #4

Merged
merged 3 commits into from
Apr 8, 2018
Merged

Enable various HTTP methods #4

merged 3 commits into from
Apr 8, 2018

Conversation

peteraba
Copy link
Contributor

@peteraba peteraba commented Apr 8, 2018

#3

RenderJSON(w, http.StatusOK, NewResponse("cool"))
}

//GetEndpoint renders registered endpoints.
func GetEndpoint(w http.ResponseWriter, r *http.Request) {
func getCacheKeys(endpoint, httpMethod string) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this makes method makes less sense right now, but will be needed to add further object "types" to the store.

@gernest
Copy link
Owner

gernest commented Apr 8, 2018

Everything looks okay to me. Just the few changes I suggested in the comments and we are good.

@peteraba
Copy link
Contributor Author

peteraba commented Apr 8, 2018

@gernest please commit your comments. 😉

api.go Outdated
err := json.NewEncoder(w).Encode(value)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Error(w, err.Error(), code)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error happened when encoding the value internaly. I think StatusInternalServerError is the right status for this since it has nothing to do with the api consumer.

api.go Outdated
return
}
RenderJSON(w, http.StatusNotFound, NewResponse("apidemic: "+endpoint+" is not found"))
RenderJSON(w, http.StatusNotFound, NewResponse("apidemic: "+vars["endpoint"]+" has no "+r.Method+" endpoint"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use fmt.Sprintf() to format the message.

@peteraba
Copy link
Contributor Author

peteraba commented Apr 8, 2018

I fixed the errors, will try to check why the build is failing.

@gernest gernest merged commit 0705d31 into gernest:master Apr 8, 2018
makasim referenced this pull request in makasim/apidemic Oct 3, 2019
string(3127) "MongoDB\Driver\Exception\BulkWriteException: Updating the
path 'message.reply_markup.inline_keyboard.0' would create a conflict at
'message.reply_markup.inline_keyboard' in
/app/vendor/mongodb/mongodb/src/Operation/Update.php:179
app_1      | Stack trace:
app_1      | #0
/app/vendor/mongodb/mongodb/src/Operation/Update.php(179):
MongoDB\Driver\Server->executeBulkWrite('avita.pvm_token',
Object(MongoDB\Driver\BulkWrite), Array)
app_1      | #1
/app/vendor/mongodb/mongodb/src/Operation/UpdateOne.php(105):
MongoDB\Operation\Update->execute(Object(MongoDB\Driver\Server))
app_1      | #2 /app/vendor/mongodb/mongodb/src/Collection.php(1033):
MongoDB\Operation\UpdateOne->execute(Object(MongoDB\Driver\Server))
app_1      | #3 /app/vendor/formapro/yadm/src/Storage.php(161):
MongoDB\Collection->updateOne(Array, Array, Array)
app_1      | #4
/app/vendor/formapro/pvm/src/Yadm/StandaloneTokenDAL.php(98):
Formapro\Yadm\Storage->update(Object(App\Model\PvmToken))
app_1      | #5 /app/vendor/formapro/pvm/src/ProcessEngine.php(289):
Formapro\Pvm\Yadm\StandaloneTokenDAL->persistToken(Object(App\Model\PvmToken))
app_1      | #6 /app/vendor/formapro/pvm/src/ProcessEngine.php(217):
Formapro\Pvm\ProcessEngine->persistToken(Object(App\Model\PvmToken))
app_1      | gernest#7 /app/vendor/formapro/pvm/src/ProcessEngine.php(251):
Formapro\Pvm\ProcessEngine->doProceed(Object(App\Model\PvmToken))
app_1      | gernest#8 /app/vendor/formapro/pvm/src/ProcessEngine.php(188):
Formapro\Pvm\ProcessEngine->transition(Object(App\Model\PvmToken))
app_1      | gernest#9 /app/vendor/formapro/pvm/src/ProcessEngine.php(78):
Formapro\Pvm\ProcessEngine->doProceed(Object(App\Model\PvmToken))
app_1      | gernest#10 /app/src/Service/PvmHandler.php(132):
Formapro\Pvm\ProcessEngine->proceed(Object(App\Model\PvmToken))
app_1      | gernest#11 [internal function]:
App\Service\PvmHandler->App\Service\{closure}(Object(App\Model\PvmToken),
Object(App\Storage\PvmTokenStorage))
app_1      | gernest#12 /app/vendor/formapro/yadm/src/Storage.php(300):
call_user_func(Object(Closure), Object(App\Model\PvmToken),
Object(App\Storage\PvmTokenStorage))
app_1      | gernest#13 /app/src/Storage/PvmStorage.php(70):
Formapro\Yadm\Storage->lock(Object(MongoDB\BSON\ObjectId),
Object(Closure))
app_1      | #14 /app/src/Service/PvmHandler.php(137):
App\Storage\PvmStorage->lockToken(Object(App\Model\PvmToken),
Object(Closure))
app_1      | #15 /app/src/Service/PvmHandler.php(114):
App\Service\PvmHandler->handleToken(Object(App\Model\PvmToken))
app_1      | #16
/app/src/Controller/TelegramUpdatesHookController.php(31):
App\Service\PvmHandler->handleUpdate(Object(Formapro\TelegramBot\Update))
app_1      | #17 /app/vendor/symfony/http-kernel/HttpKernel.php(150):
App\Controller\TelegramUpdatesHookController->__invoke(Object(Symfony\Component\HttpFoundation\Request),
'725382688:AAFZQ...', Object(Formapro\TelegramBot\Bot),
Object(App\Service\PvmHandler), Object(Symfony\Bridge\Monolog\Logger))
app_1      | #18 /app/vendor/symfony/http-kernel/HttpKernel.php(67):
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request),
1)
app_1      | #19 /app/vendor/symfony/http-kernel/Kernel.php(198):
Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request),
1, true)
app_1      | #20 /app/public/index.php(25):
Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
app_1      | #21 {main}"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants