Ejemplo n.º 1
0
func runAPI(wg *sync.WaitGroup) {
	mux := goji.NewMux()

	// List all webhooks
	mux.HandleFuncC(
		pat.Get("/webhooks"),
		func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
			ui := uhttp.UI{ctx, r, w}
			kase := usecase.ListWebhooks{
				DB:  &drivers.DB,
				Out: &ui,
			}

			if err := kase.Exec(); err != nil {
				fail(err)
			}
		},
	)

	// Create a new webhook
	mux.HandleFuncC(
		pat.Post("/webhooks"),
		func(ctx context.Context, w http.ResponseWriter, r *http.Request) {},
	)

	// Delete a webhook
	mux.HandleFuncC(
		pat.Delete("/webhooks/:id"),
		func(ctx context.Context, w http.ResponseWriter, r *http.Request) {},
	)

	http.ListenAndServe("localhost:8000", mux)
	wg.Done()
}
Ejemplo n.º 2
0
var editWebhook = &cobra.Command{
	Use:   "edit [id]",
	Short: "edit a webhook",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			cmd.Usage()
			os.Exit(1)
		}

		id := args[0]
		_ = id
		fmt.Println("TODO: open editor to configure webhook")
		fmt.Println("TODO: run UpdateWebhook use case")
	},
}

var listWebhooks = &cobra.Command{
	Use:   "ls",
	Short: "list webhooks",
	Run: func(cmd *cobra.Command, args []string) {
		kase := usecase.ListWebhooks{
			DB:  &drivers.DB,
			Out: &uis.Console,
		}

		if err := kase.Exec(); err != nil {
			fail(err)
		}
	},
}