Skip to content

Commit

Permalink
Refactor appx
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLuo committed Apr 9, 2022
1 parent 09c7c20 commit a434bc4
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 166 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/RussellLuo/kun
go 1.16

require (
github.com/RussellLuo/appx v0.0.0-20210610081121-2d2842cc1993
github.com/RussellLuo/appx v0.0.0-20220409155050-308f2cb0b320
github.com/RussellLuo/micron/cron v0.0.0-20220211083222-9c7043d2a83a
github.com/RussellLuo/validating/v2 v2.1.1
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-kit/kit v0.10.0
github.com/prometheus/client_golang v1.3.0
golang.org/x/net v0.0.0-20201021035429-f5854403a974
golang.org/x/tools v0.0.0-20201029135353-690a3c245f28
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
golang.org/x/tools v0.1.10
google.golang.org/grpc v1.36.0
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.2.8
Expand Down
34 changes: 20 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/RussellLuo/appx v0.0.0-20210610081121-2d2842cc1993 h1:/RgwpoWixH1ZLjJPJaOWTnwn7tn+biisb3m8e8qoeyg=
github.com/RussellLuo/appx v0.0.0-20210610081121-2d2842cc1993/go.mod h1:BYiSO63uqNy81Mlv9EfnJ+wNr+vkgAohKMgeDyhWu1s=
github.com/RussellLuo/appx v0.0.0-20220409155050-308f2cb0b320 h1:27i5zZnCrBHlxIeHZmsVIqP2SExlNnoc5PcFTaS4EVg=
github.com/RussellLuo/appx v0.0.0-20220409155050-308f2cb0b320/go.mod h1:BYiSO63uqNy81Mlv9EfnJ+wNr+vkgAohKMgeDyhWu1s=
github.com/RussellLuo/micron/cron v0.0.0-20220211083222-9c7043d2a83a h1:vyLrurbny6mKe6enmLFmvzzbWux7UD3lYOCbxvNM+vA=
github.com/RussellLuo/micron/cron v0.0.0-20220211083222-9c7043d2a83a/go.mod h1:Mq+QY1YdEN9eupmxn4KJoq4ZNjxSKcBiyNshmJ3ZGcA=
github.com/RussellLuo/validating/v2 v2.1.1 h1:lIqtzIgoeW1Rs4Oouo6Twk0HRxFjKgEZARMuOlT4hh0=
Expand Down Expand Up @@ -265,7 +265,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
Expand All @@ -284,7 +284,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand All @@ -293,8 +293,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -311,8 +311,9 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -321,7 +322,6 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -339,12 +339,18 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand All @@ -361,8 +367,8 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20201029135353-690a3c245f28 h1:KmEPH4S/AVTMSlbgNWC4xKvfsqvw/dNDUo/bGDqbDdo=
golang.org/x/tools v0.0.0-20201029135353-690a3c245f28/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
39 changes: 6 additions & 33 deletions pkg/appx/cronapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,25 @@ package cronapp

import (
"github.com/RussellLuo/appx"
"github.com/RussellLuo/kun/pkg/appx/wrapper"
)

type App struct {
*appx.App

wrapper *wrapper.InitWrapper

scheduler string
expression string
}

func New(name string, instance appx.Initializer) *App {
w := wrapper.New(instance)
return &App{
App: appx.New(name, w),
wrapper: w,
}
func New(name string, instance appx.Instance) *App {
return &App{App: appx.New(name, instance)}
}

func (a *App) ScheduledBy(scheduler string, expression string) *App {
a.scheduler = scheduler
a.App.Require(scheduler)

a.expression = expression
a.wrapper.AfterInitFunc(a.afterInit)
func (a *App) ScheduledBy(scheduler, expression string) *App {
m := ScheduledBy(a.App.Name, scheduler, expression)
a.App.Instance = appx.Standardize(m(a.App.Instance))

a.App.Require(scheduler)
return a
}

func (a *App) Require(names ...string) *App {
a.App.Require(names...)
return a
}

func (a *App) afterInit(ctx appx.Context) error {
scheduler, err := GetCronScheduler(ctx.MustLoad(a.scheduler))
if err != nil {
return err
}

job, err := GetCronJob(a.wrapper.Instance())
if err != nil {
return err
}

scheduler.Add(a.Name, a.expression, job.Task) // nolint:errcheck
return nil
}
3 changes: 1 addition & 2 deletions pkg/appx/cronapp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"time"

"github.com/RussellLuo/appx"
"github.com/RussellLuo/micron/cron"

"github.com/RussellLuo/kun/pkg/appx/cronapp"
"github.com/RussellLuo/micron/cron"
)

type task func()
Expand Down
43 changes: 41 additions & 2 deletions pkg/appx/cronapp/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,47 @@ package cronapp

import (
"fmt"

"github.com/RussellLuo/appx"
)

func ScheduledBy(name, scheduler, expression string) appx.Middleware {
return func(next appx.Instance) appx.Instance {
return middleware{
Standard: appx.Standardize(next),
name: name,
scheduler: scheduler,
expression: expression,
}
}
}

type middleware struct {
appx.Standard
name string
scheduler string
expression string
}

func (m middleware) Init(ctx appx.Context) error {
if err := m.Standard.Init(ctx); err != nil {
return err
}

scheduler, err := getCronScheduler(ctx.MustLoad(m.scheduler))
if err != nil {
return err
}

job, err := getCronJob(m.Standard.Instance())
if err != nil {
return err
}

_ = scheduler.Add(m.name, m.expression, job.Task)
return nil
}

// Scheduler represents a cron scheduler.
type Scheduler interface {
Add(name, expr string, task func()) error
Expand All @@ -24,7 +63,7 @@ type CronJob interface {
Job() Job
}

func GetCronScheduler(instance interface{}) (Scheduler, error) {
func getCronScheduler(instance interface{}) (Scheduler, error) {
r, ok := instance.(CronScheduler)
if !ok {
return nil, fmt.Errorf("instance %#v does not implement httpapp.CronScheduler", instance)
Expand All @@ -38,7 +77,7 @@ func GetCronScheduler(instance interface{}) (Scheduler, error) {
return result, nil
}

func GetCronJob(instance interface{}) (Job, error) {
func getCronJob(instance interface{}) (Job, error) {
r, ok := instance.(CronJob)
if !ok {
return nil, fmt.Errorf("instance %#v does not implement httpapp.CronJob", instance)
Expand Down
4 changes: 2 additions & 2 deletions pkg/appx/cronapp/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestGetCronScheduler(t *testing.T) {
},
}
for _, c := range cases {
router, err := GetCronScheduler(c.in)
router, err := getCronScheduler(c.in)
if router != c.wantScheduler {
t.Fatalf("Scheduler: got (%#v), want (%#v)", router, c.wantScheduler)
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestGetCronJob(t *testing.T) {
},
}
for _, c := range cases {
router, err := GetCronJob(c.in)
router, err := getCronJob(c.in)
if router != c.wantJob {
t.Fatalf("Job: got (%#v), want (%#v)", router, c.wantJob)
}
Expand Down
39 changes: 6 additions & 33 deletions pkg/appx/httpapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,25 @@ package httpapp

import (
"github.com/RussellLuo/appx"
"github.com/RussellLuo/kun/pkg/appx/wrapper"
)

type App struct {
*appx.App

wrapper *wrapper.InitWrapper

parent string
pattern string
}

func New(name string, instance appx.Initializer) *App {
w := wrapper.New(instance)
return &App{
App: appx.New(name, w),
wrapper: w,
}
func New(name string, instance appx.Instance) *App {
return &App{App: appx.New(name, instance)}
}

func (a *App) MountOn(parent string, pattern string) *App {
a.parent = parent
a.App.Require(parent)

a.pattern = pattern
a.wrapper.AfterInitFunc(a.afterInit)
func (a *App) MountOn(parent, pattern string) *App {
m := MountOn(parent, pattern)
a.App.Instance = appx.Standardize(m(a.App.Instance))

a.App.Require(parent)
return a
}

func (a *App) Require(names ...string) *App {
a.App.Require(names...)
return a
}

func (a *App) afterInit(ctx appx.Context) error {
parent, err := GetChiRouter(ctx.MustLoad(a.parent))
if err != nil {
return err
}

r, err := GetChiRouter(a.wrapper.Instance())
if err != nil {
return err
}

MountRouter(parent, a.pattern, r)
return nil
}
7 changes: 3 additions & 4 deletions pkg/appx/httpapp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"time"

"github.com/RussellLuo/appx"
"github.com/go-chi/chi"

"github.com/RussellLuo/kun/pkg/appx/httpapp"
"github.com/go-chi/chi"
)

type Hi struct {
Expand Down Expand Up @@ -108,8 +107,8 @@ func Example() {
}

// Make two HTTP requests to demonstrate that our server is running.
http.Get("http://localhost:8080/hi") // nolint:errcheck
http.Get("http://localhost:8080/bye") // nolint:errcheck
_, _ = http.Get("http://localhost:8080/hi")
_, _ = http.Get("http://localhost:8080/bye")

// Stop the greeter.
stopCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
Expand Down
Loading

0 comments on commit a434bc4

Please sign in to comment.