mirror of
https://github.com/sigmasternchen/threadule
synced 2025-03-15 08:09:01 +00:00
style(backend): the code format and the imports in one or the other place a little polished.
This commit is contained in:
parent
f5c08ef4e5
commit
0154537fde
6 changed files with 15 additions and 13 deletions
|
@ -10,7 +10,7 @@ import (
|
||||||
"threadule/backend/internal/config"
|
"threadule/backend/internal/config"
|
||||||
"threadule/backend/internal/data"
|
"threadule/backend/internal/data"
|
||||||
"threadule/backend/internal/logic"
|
"threadule/backend/internal/logic"
|
||||||
router "threadule/backend/internal/router"
|
"threadule/backend/internal/router"
|
||||||
"threadule/backend/internal/web"
|
"threadule/backend/internal/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultPasswordLength = 16
|
const (
|
||||||
const defaultPasswordCharSet = "abcdefghijklmnopqrstuvwxyz" +
|
defaultPasswordLength = 16
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
defaultPasswordCharSet = "abcdefghijklmnopqrstuvwxyz" +
|
||||||
"0123456789" +
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||||
"=!$%&+#-_.,;:"
|
"0123456789" +
|
||||||
|
"=!$%&+#-_.,;:"
|
||||||
|
)
|
||||||
|
|
||||||
func (l *Logic) defaultPassword() string {
|
func (l *Logic) defaultPassword() string {
|
||||||
builder := strings.Builder{}
|
builder := strings.Builder{}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
|
"github.com/dghubble/oauth1"
|
||||||
|
twitterOAuth "github.com/dghubble/oauth1/twitter"
|
||||||
"net/url"
|
"net/url"
|
||||||
"threadule/backend/internal/data/models"
|
"threadule/backend/internal/data/models"
|
||||||
)
|
)
|
||||||
import "github.com/dghubble/oauth1"
|
|
||||||
import "github.com/dghubble/go-twitter/twitter"
|
|
||||||
import twitterOAuth "github.com/dghubble/oauth1/twitter"
|
|
||||||
|
|
||||||
func (l *Logic) sendTweet(client *twitter.Client, tweet *models.Tweet, prevId int64) (int64, error) {
|
func (l *Logic) sendTweet(client *twitter.Client, tweet *models.Tweet, prevId int64) (int64, error) {
|
||||||
status, _, err := client.Statuses.Update(
|
status, _, err := client.Statuses.Update(
|
||||||
|
|
|
@ -3,7 +3,7 @@ package router
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
. "threadule/backend/internal/presentation"
|
"threadule/backend/internal/presentation"
|
||||||
"threadule/backend/internal/web"
|
"threadule/backend/internal/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,14 +13,14 @@ func authenticated(next web.Handler) web.Handler {
|
||||||
return func(ctx *web.Context) {
|
return func(ctx *web.Context) {
|
||||||
authHeader := ctx.Request.Header.Get("Authorization")
|
authHeader := ctx.Request.Header.Get("Authorization")
|
||||||
if !strings.HasPrefix(authHeader, authPrefix) {
|
if !strings.HasPrefix(authHeader, authPrefix) {
|
||||||
StatusResponse(ctx, http.StatusBadRequest, "Authorization header missing or malformed")
|
presentation.StatusResponse(ctx, http.StatusBadRequest, "Authorization header missing or malformed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
authHeader = strings.TrimPrefix(authHeader, authPrefix)
|
authHeader = strings.TrimPrefix(authHeader, authPrefix)
|
||||||
|
|
||||||
user, err := ctx.AppCtx.Logic.AuthenticateSession(authHeader)
|
user, err := ctx.AppCtx.Logic.AuthenticateSession(authHeader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
StatusResponse(ctx, http.StatusUnauthorized, err.Error())
|
presentation.StatusResponse(ctx, http.StatusUnauthorized, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartServer(ctx *app.Context, handler http.Handler) error {
|
func StartServer(ctx *app.Context, handler http.Handler) error {
|
||||||
ctx.Log.Info("startinhg web server")
|
ctx.Log.Info("starting web server")
|
||||||
return http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", ctx.Config.Web.Port), handler)
|
return http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", ctx.Config.Web.Port), handler)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue