Skip to content

make shorten api#5

Open
Arashi-K wants to merge 4 commits into
masterfrom
shorten-api
Open

make shorten api#5
Arashi-K wants to merge 4 commits into
masterfrom
shorten-api

Conversation

@Arashi-K

Copy link
Copy Markdown

No description provided.

@Arashi-K Arashi-K changed the title publish api key make functions to publish api key Dec 23, 2019
@Arashi-K Arashi-K changed the title make functions to publish api key make shorten api Dec 23, 2019
@Arashi-K Arashi-K self-assigned this Dec 23, 2019
@Arashi-K Arashi-K added the wip work in progress label Dec 23, 2019
Comment thread src/adapters/web/middleware.go Outdated
session, _ := web.store.Get(r, "scvl")
userID, ok := session.Values["user_id"].(uint)
userID = 1
ok = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

delete

Comment thread src/engine/page.go Outdated
Comment on lines +109 to +112
_, err = e.sqlClient.FindUserByAPIKey(req.APIKey)
if err != nil {
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if _, err = e.sqlClient.FindUserByAPIKey(req.APIKey); err != nil {
return
}

Comment thread src/engine/page.go Outdated
Comment on lines +118 to +121
err = e.sqlClient.CreatePage(page)
if err != nil {
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if err = e.sqlClient.CreatePage(page); err != nil {
return
}

Comment thread src/engine/page.go Outdated
}

page = &domain.Page{
Slug: domain.GenerateSlug(5),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2箇所以上で使うんだったら定数を定義するのもあり。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

どの部分のことですか?

Comment thread src/adapters/web/web.go Outdated
r.Handle("/logout", web.authenticate(web.logoutHandler)).Methods(http.MethodPost)
r.Handle("/shorten", web.authenticate(web.shortenHandler)).Methods(http.MethodPost)
r.HandleFunc("/api/shorten", web.shortenByAPIHandler).Methods(http.MethodPost)
r.Handle("/api/publish", web.authenticate(web.publishAPIKeyHandler)).Methods(http.MethodPost)

@ttexan1 ttexan1 Dec 26, 2019

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

path名がこれだと(keyではなく)apiをpublishすることになりそう。
あと、RestでURLを考える場合は基本的に何をするかはAction(get post put delete)で定義されているから、Path中に動詞を入れると冗長になると言われている。
例えば /api/key とかの方がいいかも

@Arashi-K Arashi-K removed the wip work in progress label Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants