diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..498b348 --- /dev/null +++ b/.air.toml @@ -0,0 +1,37 @@ +root = "." +testdata_dir = "data" +tmp_dir = "tmp" + +[build] + args_bin = [] + bin = "./tmp/main" + cmd = "go build -o ./tmp/main ." + delay = 1000 + exclude_dir = ["assets", "tmp", "vendor", "testdata"] + exclude_file = [] + exclude_regex = ["_test.go"] + exclude_unchanged = false + follow_symlink = false + full_bin = "" + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "html"] + kill_delay = "0s" + log = "build-errors.log" + send_interrupt = false + stop_on_error = true + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + time = false + +[misc] + clean_on_exit = false + +[screen] + clear_on_rebuild = false diff --git a/.gitignore b/.gitignore index cb6d70e..c7d5594 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ data/ !*.secret local.mk logzio.yml +tmp/ diff --git a/main.go b/main.go index e9c9834..cb28ab5 100644 --- a/main.go +++ b/main.go @@ -60,7 +60,7 @@ func run(ctx context.Context) error { return err } - svc, err := msgbus.New(ctx, es) + svc, err := msgbus.New(ctx, es, env("EV_BASE_URL", "https://ev.sour.is/inbox/")) if err != nil { return err } diff --git a/pkg/msgbus/service.go b/pkg/msgbus/service.go index 968cee3..bcecc1f 100644 --- a/pkg/msgbus/service.go +++ b/pkg/msgbus/service.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "net/http" + "path" "strconv" "strings" "time" @@ -20,17 +21,18 @@ import ( ) type service struct { - es *es.EventStore + baseURL string + es *es.EventStore } -func New(ctx context.Context, es *es.EventStore) (*service, error) { +func New(ctx context.Context, es *es.EventStore, baseURL string) (*service, error) { ctx, span := logz.Span(ctx) defer span.End() if err := event.Register(ctx, &PostEvent{}); err != nil { return nil, err } - return &service{es}, nil + return &service{baseURL, es}, nil } var upgrader = websocket.Upgrader{ @@ -143,7 +145,7 @@ func (s *service) getUser(w http.ResponseWriter, r *http.Request) { Endpoint string `json:"endpoint"` Key string `json:"key"` }{ - Endpoint: a.Inbox.String(), + Endpoint: path.Join(s.baseURL, a.Inbox.String()), Key: a.Pubkey.ID().String(), }) if err != nil {