forked from wgroeneveld/go-jamming
implement gofmt and add a filewatcher in Goland
This commit is contained in:
parent
3933e4d43b
commit
d4c854ef81
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectTasksOptions">
|
||||
<TaskOptions isEnabled="true">
|
||||
<option name="arguments" value="fmt $FilePath$" />
|
||||
<option name="checkSyntaxErrors" value="true" />
|
||||
<option name="description" />
|
||||
<option name="exitCodeBehavior" value="ERROR" />
|
||||
<option name="fileExtension" value="go" />
|
||||
<option name="immediateSync" value="false" />
|
||||
<option name="name" value="go fmt" />
|
||||
<option name="output" value="$FilePath$" />
|
||||
<option name="outputFilters">
|
||||
<array />
|
||||
</option>
|
||||
<option name="outputFromStdout" value="false" />
|
||||
<option name="program" value="$GoExecPath$" />
|
||||
<option name="runOnExternalChanges" value="false" />
|
||||
<option name="scopeName" value="Project Files" />
|
||||
<option name="trackOnlyRoot" value="true" />
|
||||
<option name="workingDir" value="$ProjectFileDir$" />
|
||||
<envs>
|
||||
<env name="GOROOT" value="$GOROOT$" />
|
||||
<env name="GOPATH" value="$GOPATH$" />
|
||||
<env name="PATH" value="$GoBinDirs$" />
|
||||
</envs>
|
||||
</TaskOptions>
|
||||
</component>
|
||||
</project>
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
package index
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"brainbaking.com/go-jamming/common"
|
||||
)
|
||||
|
@ -14,4 +13,3 @@ func Handle(conf *common.Config) http.HandlerFunc {
|
|||
fmt.Fprintf(w, "This is a Jamstack microservice endpoint.\nWanna start jammin' too? Go to https://github.com/wgroeneveld/go-jamming !")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package app
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package mf
|
||||
|
||||
import (
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package mf
|
||||
|
||||
import (
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"strings"
|
||||
"time"
|
||||
"willnorris.com/go/microformats"
|
||||
"brainbaking.com/go-jamming/common"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
|
||||
package pingback
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"github.com/rs/zerolog/log"
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"brainbaking.com/go-jamming/app/webmention/recv"
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"brainbaking.com/go-jamming/rest"
|
||||
"encoding/xml"
|
||||
"github.com/rs/zerolog/log"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
@ -94,5 +93,3 @@ func pingbackError(w http.ResponseWriter, msg string) {
|
|||
w.WriteHeader(200)
|
||||
w.Write([]byte(xml))
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package send
|
||||
|
||||
import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"brainbaking.com/go-jamming/rest"
|
||||
"github.com/rs/zerolog/log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package send
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"brainbaking.com/go-jamming/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pingback
|
||||
|
||||
import (
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"encoding/xml"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package app
|
||||
|
||||
import (
|
||||
|
@ -19,4 +18,3 @@ func (s *server) routes() {
|
|||
s.router.HandleFunc("/webmention/{domain}/{token}", s.authorizedOnly(webmention.HandleGet(cnf))).Methods("GET")
|
||||
s.router.HandleFunc("/webmention/{domain}/{token}", s.authorizedOnly(webmention.HandlePut(cnf))).Methods("PUT")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package app
|
||||
|
||||
import (
|
||||
|
@ -17,7 +16,9 @@ type server struct {
|
|||
}
|
||||
|
||||
// mimicing NotFound: https://golang.org/src/net/http/server.go?s=64787:64830#L2076
|
||||
func unauthorized(w http.ResponseWriter, r *http.Request) { http.Error(w, "401 unauthorized", http.StatusUnauthorized) }
|
||||
func unauthorized(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "401 unauthorized", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
func (s *server) authorizedOnly(h http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
|
||||
package webmention
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gorilla/mux"
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"brainbaking.com/go-jamming/app/webmention/recv"
|
||||
"brainbaking.com/go-jamming/app/webmention/send"
|
||||
"fmt"
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
|
||||
"brainbaking.com/go-jamming/common"
|
||||
|
@ -71,4 +70,3 @@ func HandlePost(conf *common.Config) http.HandlerFunc {
|
|||
rest.Accept(w)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
package recv
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"brainbaking.com/go-jamming/rest"
|
||||
"encoding/json"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -16,7 +15,6 @@ import (
|
|||
"willnorris.com/go/microformats"
|
||||
)
|
||||
|
||||
|
||||
// used as a "class" to iject dependencies, just to be able to test. Do NOT like htis.
|
||||
// Is there a better way? e.g. in validate, I just pass rest.Client as an arg. Not great either.
|
||||
type Receiver struct {
|
||||
|
@ -50,7 +48,6 @@ func getHEntry(data *microformats.Data) *microformats.Microformat {
|
|||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (recv *Receiver) processSourceBody(body string, wm mf.Mention) {
|
||||
if !strings.Contains(body, wm.Target) {
|
||||
log.Warn().Str("target", wm.Target).Msg("ABORT: no mention of target found in html src of source!")
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
package recv
|
||||
|
||||
import (
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -21,7 +20,6 @@ var conf = &common.Config{
|
|||
DataPath: "testdata",
|
||||
}
|
||||
|
||||
|
||||
func TestConvertWebmentionToPath(t *testing.T) {
|
||||
wm := mf.Mention{
|
||||
Source: "https://brainbaking.com",
|
||||
|
@ -181,4 +179,3 @@ func TestProcessSourceBodyAbortsIfNoMentionOfTargetFoundInSourceHtml(t *testing.
|
|||
receiver.processSourceBody("<html>my nice body</html>", wm)
|
||||
assert.NoFileExists(t, wm.AsPath(conf))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package send
|
||||
|
||||
import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"brainbaking.com/go-jamming/app/mf"
|
||||
"brainbaking.com/go-jamming/app/pingback/send"
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"brainbaking.com/go-jamming/rest"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type Sender struct {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package webmention
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
package webmention
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"brainbaking.com/go-jamming/common"
|
||||
"brainbaking.com/go-jamming/mocks"
|
||||
|
@ -17,14 +16,18 @@ type httpReqMock struct {
|
|||
type httpHeaderMock struct {
|
||||
contentType string
|
||||
}
|
||||
|
||||
func (mock *httpHeaderMock) Get(key string) string {
|
||||
return mock.contentType
|
||||
}
|
||||
func (mock *httpReqMock) FormValue(key string) string {
|
||||
switch key {
|
||||
case "source": return mock.source
|
||||
case "target": return mock.target
|
||||
default: return ""
|
||||
case "source":
|
||||
return mock.source
|
||||
case "target":
|
||||
return mock.target
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
func buildHttpReq(source string, target string) *httpReqMock {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package common
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// neat trick! https://medium.com/@matryer/meet-moq-easily-mock-interfaces-in-go-476444187d10
|
||||
|
|
|
@ -2,9 +2,9 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
func mainz() {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package rest
|
||||
|
||||
import (
|
||||
|
@ -45,7 +44,6 @@ func (client *HttpClient) GetBody(url string) (string, error) {
|
|||
return string(body), nil
|
||||
}
|
||||
|
||||
|
||||
func (client *HttpClient) Get(url string) (*http.Response, error) {
|
||||
return http.Get(url)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package rest
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package rest
|
||||
|
||||
// great, these are needed to do the structural typing for the tests...
|
||||
|
|
Loading…
Reference in New Issue