Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types and allow empty app ID #41

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions skillserver/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,27 @@ type EchoIntent struct {
}

type EchoSlot struct {
Name string `json:"name"`
Value string `json:"value"`
Name string `json:"name"`
Value string `json:"value"`
Resolutions struct {
ResolutionsPerAuthority []EchoResolution `json:"resolutionsPerAuthority"`
} `json:"resolutions"`
ConfirmationStatus string `json:"confirmationStatus"`
}

type EchoResolution struct {
Authority string `json:"authority"`
Status struct {
Code string `json:"code"`
} `json:"status"`
Values *[]ResolutionValue `json:"values"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why make this a pointer to a slice? Under the hood a slice uses a pointer.

}

type ResolutionValue struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are prefixing other types with Echo perhaps this should be EchoResolutionValue?

Value struct {
Name string `json:"name"`
ID string `json:"id"`
} `json:"value"`
}

// Response Types
Expand Down
5 changes: 3 additions & 2 deletions skillserver/skillserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ func verifyJSON(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
return
}

// Check the app id
if !echoReq.VerifyAppID(Applications[r.URL.Path].(EchoApplication).AppID) {
if Applications[r.URL.Path] != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should add this nil check logic to VerifyAppID? It would then be much cleaner:

if !echoReq.VerifyAppID() {
    HTTPError(...)
}

Applications[r.URL.Path].(EchoApplication).AppID != "" &&
!echoReq.VerifyAppID(Applications[r.URL.Path].(EchoApplication).AppID) {
HTTPError(w, "Echo AppID mismatch!", "Bad Request", 400)
return
}
Expand Down