diff --git a/.gitignore b/.gitignore index bcc58a5..80784ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ # bin -/cmd/httpway/main -/cmd/httpway/httpway +/cmd/pipehub/main +/cmd/pipehub/pipehub # temporary files /bin /test.cover -/cmd/httpway/httpway.hcl +/cmd/pipehub/pipehub.hcl # generated files /go.mod.backup diff --git a/Makefile b/Makefile index 5e29f44..e84ba0e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -PROJECT_PATH = /opt/httpway -DOCKER_CI_IMAGE = registry.gitlab.com/httpway/httpway/ci +PROJECT_PATH = /opt/pipehub +DOCKER_CI_IMAGE = registry.gitlab.com/pipehub/pipehub/ci DOCKER_CI_VERSION = 1 -CONFIG_PATH ?= $(CURDIR)/cmd/httpway/httpway.hcl +CONFIG_PATH ?= $(CURDIR)/cmd/pipehub/pipehub.hcl WORKSPACE_PATH = $(CURDIR) configure: @@ -10,12 +10,12 @@ configure: @git config branch.master.mergeoptions "--ff-only" build: - @go build -tags "$(TAGS)" -o cmd/httpway/httpway cmd/httpway/*.go + @go build -tags "$(TAGS)" -o cmd/pipehub/pipehub cmd/pipehub/*.go generate: @rm -f handler_dynamic.go @make build - @./cmd/httpway/httpway generate -c $(CONFIG_PATH) -w $(WORKSPACE_PATH) + @./cmd/pipehub/pipehub generate -c $(CONFIG_PATH) -w $(WORKSPACE_PATH) @TAGS=handler make build pre-pr: go-test go-linter go-linter-vendor docker-linter diff --git a/client.go b/client.go index c7c1312..3754612 100644 --- a/client.go +++ b/client.go @@ -1,4 +1,4 @@ -package httpway +package pipehub import ( "context" @@ -54,14 +54,14 @@ type ClientConfigHost struct { Handler string } -// Client is httpway entrypoint. +// Client is pipehub entrypoint. type Client struct { cfg ClientConfig server *server handlerManager *handlerManager } -// Start httpway. +// Start pipehub. func (c *Client) Start() error { if err := c.server.start(); err != nil { return errors.Wrap(err, "server start error") @@ -69,7 +69,7 @@ func (c *Client) Start() error { return nil } -// Stop the httpway. +// Stop the pipehub. func (c *Client) Stop(ctx context.Context) error { if err := c.server.stop(ctx); err != nil { return errors.Wrap(err, "server stop error") @@ -97,7 +97,7 @@ func (c *Client) init(cfg ClientConfig) error { return nil } -// NewClient return a configured httpway client. +// NewClient return a configured pipehub client. func NewClient(cfg ClientConfig) (Client, error) { var c Client if err := c.init(cfg); err != nil { diff --git a/cmd/httpway/main.go b/cmd/pipehub/main.go similarity index 75% rename from cmd/httpway/main.go rename to cmd/pipehub/main.go index 60ab43f..eddfce1 100644 --- a/cmd/httpway/main.go +++ b/cmd/pipehub/main.go @@ -8,16 +8,16 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/httpway/httpway" + "github.com/pipehub/pipehub" ) var done = make(chan os.Signal, 1) func main() { - var rootCmd = &cobra.Command{Use: "httpway"} + var rootCmd = &cobra.Command{Use: "pipehub"} rootCmd.AddCommand(cmdStart(), cmdGenerate()) if err := rootCmd.Execute(); err != nil { - err = errors.Wrap(err, "httpway cli initialization error") + err = errors.Wrap(err, "pipehub cli initialization error") fatal(err) } } @@ -30,7 +30,7 @@ func cmdStart() *cobra.Command { Long: `Start the application server.`, Run: cmdStartRun(&configPath), } - cmd.Flags().StringVarP(&configPath, "config", "c", "./httpway.hcl", "config file path") + cmd.Flags().StringVarP(&configPath, "config", "c", "./pipehub.hcl", "config file path") return &cmd } @@ -51,14 +51,14 @@ func cmdStartRun(configPath *string) func(*cobra.Command, []string) { ctxShutdown, ctxShutdownCancel := rawCfg.ctxShutdown() defer ctxShutdownCancel() - c, err := httpway.NewClient(cfg) + c, err := pipehub.NewClient(cfg) if err != nil { - err = errors.Wrap(err, "httpway new client error") + err = errors.Wrap(err, "pipehub new client error") fatal(err) } if err := c.Start(); err != nil { - err = errors.Wrap(err, "httpway start error") + err = errors.Wrap(err, "pipehub start error") fatal(err) } @@ -66,15 +66,15 @@ func cmdStartRun(configPath *string) func(*cobra.Command, []string) { go func() { <-ctxShutdown.Done() - fmt.Println("httpway did not gracefuly stopped") + fmt.Println("pipehub did not gracefuly stopped") os.Exit(1) }() if err := c.Stop(ctxShutdown); err != nil { - err = errors.Wrap(err, "httpway stop error") + err = errors.Wrap(err, "pipehub stop error") fatal(err) } - fmt.Println("httpway stopped") + fmt.Println("pipehub stopped") } } @@ -87,7 +87,7 @@ func cmdGenerate() *cobra.Command { handlers defined at the configuration file.`, Run: cmdGenerateRun(&configPath, &workspacePath), } - cmd.Flags().StringVarP(&configPath, "config", "c", "./httpway.hcl", "config file path") + cmd.Flags().StringVarP(&configPath, "config", "c", "./pipehub.hcl", "config file path") cmd.Flags().StringVarP(&workspacePath, "workspace", "w", "", "workspace path") return &cmd } @@ -104,14 +104,14 @@ func cmdGenerateRun(configPath, workspacePath *string) func(*cobra.Command, []st fs := afero.NewBasePathFs(afero.NewOsFs(), *workspacePath) cfg.Filesystem = fs - g, err := httpway.NewGenerate(cfg) + g, err := pipehub.NewGenerate(cfg) if err != nil { - err = errors.Wrap(err, "httpway generate initialization error") + err = errors.Wrap(err, "pipehub generate initialization error") fatal(err) } if err = g.Do(); err != nil { - err = errors.Wrap(err, "httpway generate execute error") + err = errors.Wrap(err, "pipehub generate execute error") fatal(err) } } diff --git a/cmd/httpway/httpway.go b/cmd/pipehub/pipehub.go similarity index 89% rename from cmd/httpway/httpway.go rename to cmd/pipehub/pipehub.go index d9f2793..b7f01fc 100644 --- a/cmd/httpway/httpway.go +++ b/cmd/pipehub/pipehub.go @@ -13,7 +13,7 @@ import ( "github.com/mitchellh/mapstructure" "github.com/pkg/errors" - "github.com/httpway/httpway" + "github.com/pipehub/pipehub" ) type config struct { @@ -35,10 +35,10 @@ func (c config) valid() error { return nil } -func (c config) toGenerateConfig() httpway.GenerateConfig { - var cfg httpway.GenerateConfig +func (c config) toGenerateConfig() pipehub.GenerateConfig { + var cfg pipehub.GenerateConfig for _, handler := range c.Handler { - cfg.Handler = append(cfg.Handler, httpway.GenerateConfigHandler{ + cfg.Handler = append(cfg.Handler, pipehub.GenerateConfigHandler{ Alias: handler.Alias, Path: handler.Path, Version: handler.Version, @@ -47,14 +47,14 @@ func (c config) toGenerateConfig() httpway.GenerateConfig { return cfg } -func (c config) toClientConfig() httpway.ClientConfig { - cfg := httpway.ClientConfig{ +func (c config) toClientConfig() pipehub.ClientConfig { + cfg := pipehub.ClientConfig{ AsyncErrHandler: asyncErrHandler, - Host: make([]httpway.ClientConfigHost, 0, len(c.Host)), + Host: make([]pipehub.ClientConfigHost, 0, len(c.Host)), } for _, host := range c.Host { - cfg.Host = append(cfg.Host, httpway.ClientConfigHost{ + cfg.Host = append(cfg.Host, pipehub.ClientConfigHost{ Endpoint: host.Endpoint, Origin: host.Origin, Handler: host.Handler, @@ -68,7 +68,7 @@ func (c config) toClientConfig() httpway.ClientConfig { } if len(c.Server[0].HTTP) > 0 { - cfg.Server.HTTP = httpway.ClientConfigServerHTTP{ + cfg.Server.HTTP = pipehub.ClientConfigServerHTTP{ Port: c.Server[0].HTTP[0].Port, } } diff --git a/cmd/httpway/httpway.sample.hcl b/cmd/pipehub/pipehub.sample.hcl similarity index 87% rename from cmd/httpway/httpway.sample.hcl rename to cmd/pipehub/pipehub.sample.hcl index 6f5e6c7..2558912 100644 --- a/cmd/httpway/httpway.sample.hcl +++ b/cmd/pipehub/pipehub.sample.hcl @@ -18,7 +18,7 @@ host { } handler { - path = "github.com/httpway/handler" + path = "github.com/pipehub/handler" version = "v0.5.1" alias = "base" } diff --git a/cmd/httpway/httpway_test.go b/cmd/pipehub/pipehub_test.go similarity index 91% rename from cmd/httpway/httpway_test.go rename to cmd/pipehub/pipehub_test.go index 4522e9b..a918318 100644 --- a/cmd/httpway/httpway_test.go +++ b/cmd/pipehub/pipehub_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/httpway/httpway" + "github.com/pipehub/pipehub" ) func TestConfigValid(t *testing.T) { @@ -83,12 +83,12 @@ func TestConfigToGenerateConfig(t *testing.T) { tests := []struct { name string config config - expected []httpway.GenerateConfigHandler + expected []pipehub.GenerateConfigHandler }{ { "success #1", config{}, - []httpway.GenerateConfigHandler{}, + []pipehub.GenerateConfigHandler{}, }, { "success #2", @@ -106,7 +106,7 @@ func TestConfigToGenerateConfig(t *testing.T) { }, }, }, - []httpway.GenerateConfigHandler{ + []pipehub.GenerateConfigHandler{ { Path: "path1", Version: "version1", @@ -133,7 +133,7 @@ func TestConfigToClientConfig(t *testing.T) { tests := []struct { name string config config - expected httpway.ClientConfig + expected pipehub.ClientConfig }{ { "success #1", @@ -141,9 +141,9 @@ func TestConfigToClientConfig(t *testing.T) { Host: []configHost{}, Server: []configServer{}, }, - httpway.ClientConfig{ - Host: []httpway.ClientConfigHost{}, - Server: httpway.ClientConfigServer{}, + pipehub.ClientConfig{ + Host: []pipehub.ClientConfigHost{}, + Server: pipehub.ClientConfigServer{}, }, }, { @@ -177,8 +177,8 @@ func TestConfigToClientConfig(t *testing.T) { }, }, }, - httpway.ClientConfig{ - Host: []httpway.ClientConfigHost{ + pipehub.ClientConfig{ + Host: []pipehub.ClientConfigHost{ { Endpoint: "endpoint1", Handler: "handler1", @@ -190,11 +190,11 @@ func TestConfigToClientConfig(t *testing.T) { Origin: "origin2", }, }, - Server: httpway.ClientConfigServer{ - HTTP: httpway.ClientConfigServerHTTP{ + Server: pipehub.ClientConfigServer{ + HTTP: pipehub.ClientConfigServerHTTP{ Port: 80, }, - Action: httpway.ClientConfigServerAction{ + Action: pipehub.ClientConfigServerAction{ NotFound: "notFound", Panic: "panic", }, @@ -282,7 +282,7 @@ func TestLoadConfig(t *testing.T) { }, Handler: []configHandler{ { - Path: "github.com/httpway/handler", + Path: "github.com/pipehub/handler", Version: "v0.5.1", Alias: "base", }, diff --git a/cmd/httpway/testdata/loadConfig.fail.1.hcl b/cmd/pipehub/testdata/loadConfig.fail.1.hcl similarity index 100% rename from cmd/httpway/testdata/loadConfig.fail.1.hcl rename to cmd/pipehub/testdata/loadConfig.fail.1.hcl diff --git a/cmd/httpway/testdata/loadConfig.fail.2.hcl b/cmd/pipehub/testdata/loadConfig.fail.2.hcl similarity index 100% rename from cmd/httpway/testdata/loadConfig.fail.2.hcl rename to cmd/pipehub/testdata/loadConfig.fail.2.hcl diff --git a/cmd/httpway/testdata/loadConfig.success.1.hcl b/cmd/pipehub/testdata/loadConfig.success.1.hcl similarity index 100% rename from cmd/httpway/testdata/loadConfig.success.1.hcl rename to cmd/pipehub/testdata/loadConfig.success.1.hcl diff --git a/cmd/httpway/testdata/loadConfig.success.2.hcl b/cmd/pipehub/testdata/loadConfig.success.2.hcl similarity index 87% rename from cmd/httpway/testdata/loadConfig.success.2.hcl rename to cmd/pipehub/testdata/loadConfig.success.2.hcl index 6f5e6c7..2558912 100644 --- a/cmd/httpway/testdata/loadConfig.success.2.hcl +++ b/cmd/pipehub/testdata/loadConfig.success.2.hcl @@ -18,7 +18,7 @@ host { } handler { - path = "github.com/httpway/handler" + path = "github.com/pipehub/handler" version = "v0.5.1" alias = "base" } diff --git a/generate.go b/generate.go index 5072ec0..dcaef16 100644 --- a/generate.go +++ b/generate.go @@ -1,4 +1,4 @@ -package httpway +package pipehub import ( "io/ioutil" @@ -171,7 +171,7 @@ func (g *Generate) doHandlerDynamic(content generateTemplateContent) error { } func (Generate) templateModCleanup(payload string) string { - i := strings.Index(payload, "// Code generated by httpway; DO NOT EDIT.") + i := strings.Index(payload, "// Code generated by pipehub; DO NOT EDIT.") if i == -1 { return payload } diff --git a/go.mod b/go.mod index cdc30d6..7e2efb0 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/httpway/httpway +module github.com/pipehub/pipehub require ( github.com/go-chi/chi v4.0.2+incompatible diff --git a/handler.go b/handler.go index 61348bb..b7d9bd9 100644 --- a/handler.go +++ b/handler.go @@ -1,6 +1,6 @@ // +build !handler -package httpway +package pipehub func fetchHandlers() ([]handler, error) { return nil, nil diff --git a/handler_manager.go b/handler_manager.go index cbb8479..e60a03f 100644 --- a/handler_manager.go +++ b/handler_manager.go @@ -1,4 +1,4 @@ -package httpway +package pipehub import ( "context" diff --git a/misc/gitlab/build.yml b/misc/gitlab/build.yml index f0cf91d..352a4e3 100644 --- a/misc/gitlab/build.yml +++ b/misc/gitlab/build.yml @@ -1,4 +1,4 @@ -build:httpway: +build:pipehub: stage: build script: - - go build -mod readonly -o bin/httpway/httpway cmd/httpway/*.go + - go build -mod readonly -o bin/pipehub/pipehub cmd/pipehub/*.go diff --git a/misc/gitlab/main.yml b/misc/gitlab/main.yml index 2378a5c..6ebb27a 100644 --- a/misc/gitlab/main.yml +++ b/misc/gitlab/main.yml @@ -1,4 +1,4 @@ -image: registry.gitlab.com/httpway/httpway/ci:1 +image: registry.gitlab.com/pipehub/pipehub/ci:1 stages: - quality diff --git a/misc/golangci/golangci.toml b/misc/golangci/golangci.toml index 8f11137..f6f1ce4 100644 --- a/misc/golangci/golangci.toml +++ b/misc/golangci/golangci.toml @@ -31,7 +31,7 @@ enable = [ check-blank = true [linters-settings.goimports] - local-prefixes = "github.com/httpway/httpway" + local-prefixes = "github.com/pipehub/pipehub" [linters-settings.gocritic] enabled-tags = [ diff --git a/httpway.go b/pipehub.go similarity index 95% rename from httpway.go rename to pipehub.go index 81bb5f7..3335fb3 100644 --- a/httpway.go +++ b/pipehub.go @@ -1,4 +1,4 @@ -package httpway +package pipehub import ( "context" diff --git a/readme.md b/readme.md index 24e9a8e..9205d85 100644 --- a/readme.md +++ b/readme.md @@ -1,11 +1,11 @@ -# HTTPWay +# Pipehub A programmable proxy server. Please, don't use it in production **yet**! It's nowhere near stable and changing too much. ## Why? Software development is getting harder and harder, on a typical medium/large solution there are lot's of servers at the request path: API Gateways, Load balancers, Cache servers, Proxies, and Firewalls, just to name a few. These generate latency and require much more engineering and monitoring to do it right. -The core idea of this project is to do more with less. HTTPWay being a programmable proxy, users can extend and customize it as needed. Features found in other servers can be added with Go packages instead of actual external services. +The core idea of this project is to do more with less. pipehub being a programmable proxy, users can extend and customize it as needed. Features found in other servers can be added with Go packages instead of actual external services. ## How? The code is extended with a thing called `handler`. It's a plain old Go code that is injected at compile time at the application. Being a Go project gives much higher flexibility at the handler because it can really be anything. @@ -25,7 +25,7 @@ host { } handler { - path = "github.com/httpway/handler" + path = "github.com/pipehub/handler" version = "v0.5.1" alias = "base" } @@ -33,13 +33,13 @@ handler { The handler points to the place where the Go code is, it should be a `go gettable` project. A handler is a generic processor that can be used on multiple hosts. A host track the endpoint the proxy gonna listen, where the origin is, and which handler gonna be used to process the requests. -A real example of a handler can be found [here](https://github.com/httpway/handler). +A real example of a handler can be found [here](https://github.com/pipehub/handler). ## How to run it? First, create a config file: ```bash -cp cmd/httpway/httpway/httpway.sample.hcl cmd/httpway/httpway/httpway.hcl -# edit cmd/httpway/httpway/httpway.hcl +cp cmd/pipehub/pipehub/pipehub.sample.hcl cmd/pipehub/pipehub/pipehub.hcl +# edit cmd/pipehub/pipehub/pipehub.hcl ``` Generate the binary: @@ -49,5 +49,5 @@ make generate Execute it: ``` -./cmd/httpway/httpway start -c ./cmd/httpway/httpway.hcl +./cmd/pipehub/pipehub start -c ./cmd/pipehub/pipehub.hcl ``` \ No newline at end of file diff --git a/server.go b/server.go index b17eee6..0b2cbd8 100644 --- a/server.go +++ b/server.go @@ -1,4 +1,4 @@ -package httpway +package pipehub import ( "context" diff --git a/template/go.mod.tmpl b/template/go.mod.tmpl index b8af422..95ff3e7 100644 --- a/template/go.mod.tmpl +++ b/template/go.mod.tmpl @@ -1,5 +1,5 @@ {{ if gt (len .Handler) 0 -}} -// Code generated by httpway; DO NOT EDIT. +// Code generated by pipehub; DO NOT EDIT. {{- if eq (len .Handler) 1 -}} {{ $handler := (index .Handler 0) }} require {{$handler.Path}} {{$handler.Revision}} diff --git a/template/handler_dynamic.go.tmpl b/template/handler_dynamic.go.tmpl index 03f0dc8..d2fc58a 100644 --- a/template/handler_dynamic.go.tmpl +++ b/template/handler_dynamic.go.tmpl @@ -1,7 +1,7 @@ -// Code generated by httpway; DO NOT EDIT. +// Code generated by pipehub; DO NOT EDIT. // +build handler -package httpway +package pipehub {{ if gt (len .Handler) 0 }} import ( "github.com/pkg/errors"