Skip to content

Instantly share code, notes, and snippets.

@brianfromlife
brianfromlife / client.go
Created August 1, 2024 21:42 — forked from xjdrew/client.go
golang tls client and server, require and verify certificate in double direction
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"
"log"
"os"
DB_HOST=localhost:27017
DB_PASS=password
DB_USER=root
DB_NAME=golang_ecs
ENV=development
JWT_SECRET=supersecretstring
JWT_EXPIRES=5
cmd
- api
internal
- api
pkg
go.mod
go.sum
package main
import (
"github.com/brianfromlife/golang-ecs/internal/api"
"github.com/brianfromlife/golang-ecs/pkg/config"
)
func main() {
cfg := config.New()
application := api.New(cfg)
package httpmodels
import (
httperrors "github.com/brianfromlife/golang-ecs/pkg/errors"
"github.com/brianfromlife/golang-ecs/pkg/models"
"github.com/labstack/echo/v4"
)
type RegisterRequest struct {
Username string `json:"username"`
package httpmodels
import (
httperrors "github.com/brianfromlife/golang-ecs/pkg/errors"
"github.com/brianfromlife/golang-ecs/pkg/models"
"github.com/labstack/echo/v4"
)
type RegisterRequest struct {
Username string `json:"username"`
package httpmodels
import (
httperrors "github.com/brianfromlife/golang-ecs/pkg/errors"
"github.com/labstack/echo/v4"
)
type RegisterRequest struct {
Username string `json:"username"`
Password string `json:"password"`
@brianfromlife
brianfromlife / errors.go
Created April 30, 2021 21:51
remove detail
package httperrors
type ApiError struct {
Message string `json:"message"`
Code int `json:"code"`
Name string `json:"name"`
Error error `json:"-"`
Validation []string `json:"validation,omitempty"`
}
package data
import (
"context"
"github.com/brianfromlife/golang-ecs/pkg/config"
"github.com/brianfromlife/golang-ecs/pkg/models"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
package httpmodels
import (
httperrors "github.com/brianfromlife/golang-ecs/pkg/errors"
"github.com/labstack/echo/v4"
)
type RegisterRequest struct {
Username string `json:"username"`
Password string `json:"password"`