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

use correct package name #6

Merged
merged 1 commit into from
Mar 31, 2024
Merged

use correct package name #6

merged 1 commit into from
Mar 31, 2024

Conversation

nehzata
Copy link
Contributor

@nehzata nehzata commented Mar 31, 2024

@alecthomas I came across this corner case. Does this change break anything?

The sample code below causes syntax errors.

package stripe

import (
    "net/http"

    "github.com/stripe/stripe-go"
)

type Service struct {
}

func New() http.Handler {
    return &Service{}
}

type StripeWebhookResp struct {
    Ok bool `json:"ok"`
}

//happy:api POST /v1/stripe/webhook
func (s *Service) StripeWebhook(r *http.Request, evt stripe.Event) (StripeWebhookResp, error) {
    return StripeWebhookResp{
        Ok: false,
    }, nil
}

happy generates the following param parse code for evt, based on the URL path to the package instead of the actual package name. stripe-go instead of stripe.

               case "webhook":
                   if len(parts) == 4 {
                     switch r.Method { // Leaf
                     case "POST":
                       var param1 stripe-go.Event

@nehzata nehzata requested a review from alecthomas March 31, 2024 14:00
@alecthomas
Copy link
Collaborator

Makes sense 👍

@nehzata nehzata merged commit fcaa5f2 into master Mar 31, 2024
2 checks passed
@nehzata nehzata deleted the valid-pkg-name branch March 31, 2024 22:58
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