update or create order

This commit is contained in:
2025-03-24 01:04:01 +01:00
parent 2fce17d528
commit 22bf9d4390
7 changed files with 124 additions and 345 deletions

View File

@@ -1,13 +1,15 @@
package controllers package controllers
import ( import (
"crypto/rand"
"encoding/hex"
"errors"
"fmt" "fmt"
"strconv"
"net/http" "net/http"
"crypto/rand" "strconv"
"encoding/hex"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gorm.io/gorm"
"example.com/gin/test/models" "example.com/gin/test/models"
//"example.com/gin/test/services" //"example.com/gin/test/services"
@@ -26,28 +28,27 @@ type CartItemController interface {
OrderHandler(*gin.Context) OrderHandler(*gin.Context)
} }
type cartItemController struct {} type cartItemController struct{}
func NewCartItemController() CartItemController { func NewCartItemController() CartItemController {
return &cartItemController{} return &cartItemController{}
} }
func GetShippingMethods() []models.Shipping { func GetShippingMethods() []models.Shipping {
return []models.Shipping{ return []models.Shipping{
{ Id: "germany", Name: "Germany (DHL)", Price: 3.99 }, {Id: "germany", Name: "Germany (DHL)", Price: 3.99},
{ Id: "international", Name: "International (DHL)", Price: 5.99 }, {Id: "international", Name: "International (DHL)", Price: 5.99},
{ Id: "pickup", Name: "Pickup", Price: 0.00 }, {Id: "pickup", Name: "Pickup", Price: 0.00},
} }
} }
func generateSessionId(length int) string { func generateSessionId(length int) string {
bytes := make([]byte, length) // 16 bytes = 128 bits bytes := make([]byte, length) // 16 bytes = 128 bits
_, err := rand.Read(bytes) _, err := rand.Read(bytes)
if err != nil { if err != nil {
panic("failed to generate session ID") panic("failed to generate session ID")
} }
return hex.EncodeToString(bytes) return hex.EncodeToString(bytes)
} }
func GetSessionId(ctx *gin.Context) string { func GetSessionId(ctx *gin.Context) string {
@@ -65,7 +66,6 @@ func GenerateToken() string {
return generateSessionId(8) return generateSessionId(8)
} }
func (rc *cartItemController) NewCartItemFromForm(ctx *gin.Context) (models.CartItem, error) { func (rc *cartItemController) NewCartItemFromForm(ctx *gin.Context) (models.CartItem, error) {
sessionId := GetSessionId(ctx) sessionId := GetSessionId(ctx)
shopItemIdStr := ctx.PostForm("ShopItemId") shopItemIdStr := ctx.PostForm("ShopItemId")
@@ -88,12 +88,12 @@ func (rc *cartItemController) NewCartItemFromForm(ctx *gin.Context) (models.Cart
itemVariant, err := repositories.ShopItems.GetVariantById(itemVariantIdStr) itemVariant, err := repositories.ShopItems.GetVariantById(itemVariantIdStr)
cartItem := models.CartItem{ cartItem := models.CartItem{
SessionId: sessionId, SessionId: sessionId,
ShopItemId: uint(shopItemId), ShopItemId: uint(shopItemId),
ShopItem: shopItem, ShopItem: shopItem,
ItemVariantId: uint(itemVariantId), ItemVariantId: uint(itemVariantId),
ItemVariant: itemVariant, ItemVariant: itemVariant,
Quantity: quantity, Quantity: quantity,
} }
return cartItem, nil return cartItem, nil
@@ -132,12 +132,12 @@ func (rc *cartItemController) NewAddressFromForm(ctx *gin.Context) (models.Addre
} }
return models.AddressInfo{ return models.AddressInfo{
FirstName: firstName, FirstName: firstName,
LastName: lastName, LastName: lastName,
Address: address, Address: address,
PostalCode: postalCode, PostalCode: postalCode,
City: city, City: city,
Country: country, Country: country,
}, nil }, nil
} }
@@ -182,25 +182,24 @@ func (rc *cartItemController) NewOrderFromForm(ctx *gin.Context) (models.Order,
} }
cartItem := models.Order{ cartItem := models.Order{
SessionId: sessionId, SessionId: sessionId,
Status: status, Status: status,
Token: token, Token: token,
Email: email, Email: email,
Comment: comment, Comment: comment,
FirstName: firstName, FirstName: firstName,
LastName: lastName, LastName: lastName,
Address: address, Address: address,
PostalCode: postalCode, PostalCode: postalCode,
City: city, City: city,
Country: country, Country: country,
Shipping: shipping.Id, Shipping: shipping.Id,
CartItems: cartItems, CartItems: cartItems,
} }
return cartItem, nil return cartItem, nil
} }
func (rc *cartItemController) Create(c *gin.Context) { func (rc *cartItemController) Create(c *gin.Context) {
cartItem, err := rc.NewCartItemFromForm(c) cartItem, err := rc.NewCartItemFromForm(c)
@@ -219,7 +218,6 @@ func (rc *cartItemController) Create(c *gin.Context) {
ReplyOK(c, "cartItem was created") ReplyOK(c, "cartItem was created")
} }
func (rc *cartItemController) Update(c *gin.Context) { func (rc *cartItemController) Update(c *gin.Context) {
cartItem, err := rc.NewCartItemFromForm(c) cartItem, err := rc.NewCartItemFromForm(c)
@@ -256,7 +254,7 @@ func (rc *cartItemController) CartItemView(c *gin.Context) {
cartItems, err := repositories.CartItems.GetAll() cartItems, err := repositories.CartItems.GetAll()
if err != nil { if err != nil {
c.HTML(http.StatusBadRequest, "cart.html", gin.H{ "data": gin.H{ "error": err } }) c.HTML(http.StatusBadRequest, "cart.html", gin.H{"data": gin.H{"error": err}})
} }
priceTotal := 0.0 priceTotal := 0.0
@@ -267,9 +265,9 @@ func (rc *cartItemController) CartItemView(c *gin.Context) {
fmt.Println("PRICE TOTAL", priceTotal) fmt.Println("PRICE TOTAL", priceTotal)
data := CreateSessionData(c, gin.H{ data := CreateSessionData(c, gin.H{
"cartItems": cartItems, "cartItems": cartItems,
"priceTotal": fmt.Sprintf("%.2f", priceTotal), //round 2 decimals "priceTotal": fmt.Sprintf("%.2f", priceTotal), //round 2 decimals
"shipping": GetShippingMethods(), "shipping": GetShippingMethods(),
}) })
c.HTML(http.StatusOK, "cart.html", data) c.HTML(http.StatusOK, "cart.html", data)
@@ -280,14 +278,14 @@ func (rc *cartItemController) AddItemHandler(c *gin.Context) {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
c.HTML(http.StatusBadRequest, "error.html", gin.H{ "error": err }) c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
return return
} }
_, err = repositories.CartItems.Create(cartItem) _, err = repositories.CartItems.Create(cartItem)
if err != nil { if err != nil {
data := CreateSessionData(c, gin.H{ data := CreateSessionData(c, gin.H{
"error": err, "error": err,
"success": "", "success": "",
}) })
@@ -304,7 +302,7 @@ func (rc *cartItemController) DeleteItemHandler(c *gin.Context) {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
data := CreateSessionData(c, gin.H{ data := CreateSessionData(c, gin.H{
"error": err, "error": err,
"success": "", "success": "",
}) })
@@ -351,7 +349,7 @@ func (rc *cartItemController) CheckoutView(c *gin.Context) {
shippingMethod := c.Query("shippingMethod") shippingMethod := c.Query("shippingMethod")
c.HTML(http.StatusOK, "checkout.html", gin.H{ c.HTML(http.StatusOK, "checkout.html", gin.H{
"askAddress": (shippingMethod != "pickup"), "askAddress": (shippingMethod != "pickup"),
"shippingMethod": shippingMethod, "shippingMethod": shippingMethod,
}) })
} }
@@ -361,15 +359,25 @@ func (rc *cartItemController) CheckoutHandler(c *gin.Context) {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
c.HTML(http.StatusBadRequest, "error.html", gin.H{ "error": err }) c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
return return
} }
//TODO: should update or create here, in case user edited addressfield existingOrder, err := repositories.Orders.GetBySession(order.SessionId)
_, err = repositories.Orders.Create(order)
if errors.Is(err, gorm.ErrRecordNotFound) {
fmt.Println("CREATE")
_, err = repositories.Orders.Create(order)
} else if err == nil {
fmt.Println("UPDATE")
order.ID = existingOrder.ID
order.CreatedAt = existingOrder.CreatedAt
repositories.Orders.Update(order)
}
if err != nil { if err != nil {
data := CreateSessionData(c, gin.H{ data := CreateSessionData(c, gin.H{
"error": err, "error": err,
"success": "", "success": "",
}) })
@@ -377,7 +385,6 @@ func (rc *cartItemController) CheckoutHandler(c *gin.Context) {
return return
} }
var shipping models.Shipping var shipping models.Shipping
for _, shippingMethod := range GetShippingMethods() { for _, shippingMethod := range GetShippingMethods() {
if shippingMethod.Id == order.Shipping { if shippingMethod.Id == order.Shipping {
@@ -393,14 +400,14 @@ func (rc *cartItemController) CheckoutHandler(c *gin.Context) {
priceTotal := priceProducts + shipping.Price priceTotal := priceProducts + shipping.Price
data := CreateSessionData(c, gin.H{ data := CreateSessionData(c, gin.H{
"error": "", "error": "",
"success": "", "success": "",
"order": order, "order": order,
"askAddress": (order.Shipping != "pickup"), "askAddress": (order.Shipping != "pickup"),
"isPreview": true, "isPreview": true,
"shipping": shipping, "shipping": shipping,
"priceProducts": fmt.Sprintf("%.2f", priceProducts), //round 2 decimals "priceProducts": fmt.Sprintf("%.2f", priceProducts), //round 2 decimals
"priceTotal": fmt.Sprintf("%.2f", priceTotal), //round 2 decimals "priceTotal": fmt.Sprintf("%.2f", priceTotal), //round 2 decimals
}) })
fmt.Println(order) fmt.Println(order)
@@ -411,7 +418,7 @@ func (rc *cartItemController) OrderView(c *gin.Context) {
shippingMethod := c.Query("shippingMethod") shippingMethod := c.Query("shippingMethod")
c.HTML(http.StatusOK, "checkout.html", gin.H{ c.HTML(http.StatusOK, "checkout.html", gin.H{
"askAddress": (shippingMethod != "pickup"), "askAddress": (shippingMethod != "pickup"),
"shippingMethod": shippingMethod, "shippingMethod": shippingMethod,
}) })
} }

20
main.go
View File

@@ -1,24 +1,24 @@
package main package main
import( import (
"os" "fmt"
"io" "io"
"net/http" "net/http"
"fmt" "os"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"example.com/gin/test/controllers" "example.com/gin/test/controllers"
"example.com/gin/test/repositories"
"example.com/gin/test/middlewares" "example.com/gin/test/middlewares"
"example.com/gin/test/repositories"
) )
var( var (
shopItemController controllers.ShopItemController = controllers.NewShopItemController() shopItemController controllers.ShopItemController = controllers.NewShopItemController()
userController controllers.UserController = controllers.UserController{} userController controllers.UserController = controllers.UserController{}
cartItemController controllers.CartItemController = controllers.NewCartItemController() cartItemController controllers.CartItemController = controllers.NewCartItemController()
authValidator middlewares.AuthValidator = middlewares.AuthValidator{} authValidator middlewares.AuthValidator = middlewares.AuthValidator{}
) )
func LoadEnvVariables() { func LoadEnvVariables() {
@@ -36,7 +36,7 @@ func setupLogOutput() {
func SetReply(ctx *gin.Context, err error, message any) { func SetReply(ctx *gin.Context, err error, message any) {
if err != nil { if err != nil {
ctx.JSON(http.StatusBadRequest, gin.H{ "error": err.Error() }) ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
} else { } else {
ctx.JSON(http.StatusOK, message) ctx.JSON(http.StatusOK, message)
} }
@@ -47,7 +47,6 @@ func main() {
repositories.InitRepositories() repositories.InitRepositories()
server := gin.New() server := gin.New()
server.Use(gin.Recovery()) server.Use(gin.Recovery())
server.Use(gin.Logger()) server.Use(gin.Logger())
@@ -106,6 +105,5 @@ func main() {
viewRoutes.POST("/passwordreset", userController.ResetHandler) viewRoutes.POST("/passwordreset", userController.ResetHandler)
} }
server.Run(":" + os.Getenv("PORT"))
server.Run(":"+os.Getenv("PORT"))
} }

View File

@@ -1,8 +1,8 @@
package repositories package repositories
import( import (
"strconv"
"gorm.io/gorm" "gorm.io/gorm"
"strconv"
"example.com/gin/test/models" "example.com/gin/test/models"
) )
@@ -11,9 +11,9 @@ type OrderRepository interface {
Create(models.Order) (models.Order, error) Create(models.Order) (models.Order, error)
GetAll() ([]models.Order, error) GetAll() ([]models.Order, error)
GetById(string) (models.Order, error) GetById(string) (models.Order, error)
GetAllBySession(string) ([]models.Order, error) GetBySession(string) (models.Order, error)
Update(models.Order) (models.Order, error) Update(models.Order) (models.Order, error)
DeleteById(string) (error) DeleteById(string) error
} }
type GORMOrderRepository struct { type GORMOrderRepository struct {
@@ -60,10 +60,9 @@ func (t *GORMOrderRepository) GetById(id string) (models.Order, error) {
return order, nil return order, nil
} }
func (r *GORMOrderRepository) GetBySession(sessionId string) (models.Order, error) {
func (r *GORMOrderRepository) GetAllBySession(sessionId string) ([]models.Order, error) { var orders models.Order
var orders []models.Order result := r.DB.Preload("CartItems").Where("session_id = ?", sessionId).First(&orders)
result := r.DB.Preload("CartItems").Where("session_id = ?", sessionId).Find(&orders)
return orders, result.Error return orders, result.Error

View File

@@ -1,19 +1,19 @@
package repositories package repositories
import( import (
"os"
"gorm.io/gorm"
"gorm.io/driver/sqlite" "gorm.io/driver/sqlite"
"gorm.io/gorm"
"os"
"example.com/gin/test/models" "example.com/gin/test/models"
) )
var( var (
ShopItems ShopItemRepository ShopItems ShopItemRepository
Users UserRepository Users UserRepository
Tags TagRepository Tags TagRepository
CartItems CartItemRepository CartItems CartItemRepository
Orders OrderRepository Orders OrderRepository
) )
func InitRepositories() { func InitRepositories() {
@@ -22,12 +22,12 @@ func InitRepositories() {
panic("failed to connect to database") panic("failed to connect to database")
} }
err = db.AutoMigrate(&models.ShopItem{}, err = db.AutoMigrate(&models.ShopItem{},
&models.ItemVariant{}, &models.ItemVariant{},
&models.User{}, &models.User{},
&models.Tag{}, &models.Tag{},
&models.CartItem{}, &models.CartItem{},
&models.Order{}) &models.Order{})
if err != nil { if err != nil {
panic("failed to migrate database") panic("failed to migrate database")

View File

@@ -566,14 +566,6 @@ video {
border-width: 0; border-width: 0;
} }
.invisible {
visibility: hidden;
}
.fixed {
position: fixed;
}
.absolute { .absolute {
position: absolute; position: absolute;
} }
@@ -591,30 +583,10 @@ video {
bottom: 0px; bottom: 0px;
} }
.left-0 {
left: 0px;
}
.right-0 { .right-0 {
right: 0px; right: 0px;
} }
.top-0 {
top: 0px;
}
.z-10 {
z-index: 10;
}
.z-20 {
z-index: 20;
}
.z-50 {
z-index: 50;
}
.col-span-12 { .col-span-12 {
grid-column: span 12 / span 12; grid-column: span 12 / span 12;
} }
@@ -642,10 +614,6 @@ video {
margin-right: auto; margin-right: auto;
} }
.-me-0\.5 {
margin-inline-end: -0.125rem;
}
.mb-2 { .mb-2 {
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
@@ -666,10 +634,6 @@ video {
margin-bottom: 2rem; margin-bottom: 2rem;
} }
.me-2 {
margin-inline-end: 0.5rem;
}
.ml-2 { .ml-2 {
margin-left: 0.5rem; margin-left: 0.5rem;
} }
@@ -690,10 +654,6 @@ video {
margin-inline-start: 0.5rem; margin-inline-start: 0.5rem;
} }
.ms-auto {
margin-inline-start: auto;
}
.mt-1 { .mt-1 {
margin-top: 0.25rem; margin-top: 0.25rem;
} }
@@ -718,18 +678,10 @@ video {
display: block; display: block;
} }
.inline-block {
display: inline-block;
}
.flex { .flex {
display: flex; display: flex;
} }
.inline-flex {
display: inline-flex;
}
.table { .table {
display: table; display: table;
} }
@@ -758,10 +710,6 @@ video {
height: 4rem; height: 4rem;
} }
.h-3 {
height: 0.75rem;
}
.h-4 { .h-4 {
height: 1rem; height: 1rem;
} }
@@ -770,14 +718,6 @@ video {
height: 2rem; height: 2rem;
} }
.h-\[460px\] {
height: 460px;
}
.h-\[calc\(100\%-1rem\)\] {
height: calc(100% - 1rem);
}
.h-auto { .h-auto {
height: auto; height: auto;
} }
@@ -786,10 +726,6 @@ video {
height: 100%; height: 100%;
} }
.h-20 {
height: 5rem;
}
.max-h-full { .max-h-full {
max-height: 100%; max-height: 100%;
} }
@@ -810,18 +746,10 @@ video {
width: 3rem; width: 3rem;
} }
.w-3 {
width: 0.75rem;
}
.w-4 { .w-4 {
width: 1rem; width: 1rem;
} }
.w-56 {
width: 14rem;
}
.w-8 { .w-8 {
width: 2rem; width: 2rem;
} }
@@ -834,14 +762,6 @@ video {
width: 100%; width: 100%;
} }
.w-20 {
width: 5rem;
}
.w-16 {
width: 4rem;
}
.max-w-2xl { .max-w-2xl {
max-width: 42rem; max-width: 42rem;
} }
@@ -858,10 +778,6 @@ video {
max-width: 80rem; max-width: 80rem;
} }
.max-w-lg {
max-width: 32rem;
}
.max-w-md { .max-w-md {
max-width: 28rem; max-width: 28rem;
} }
@@ -894,10 +810,6 @@ video {
grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-columns: repeat(12, minmax(0, 1fr));
} }
.grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.flex-col { .flex-col {
flex-direction: column; flex-direction: column;
} }
@@ -918,14 +830,6 @@ video {
justify-content: space-between; justify-content: space-between;
} }
.gap-1 {
gap: 0.25rem;
}
.gap-2 {
gap: 0.5rem;
}
.gap-4 { .gap-4 {
gap: 1rem; gap: 1rem;
} }
@@ -983,11 +887,6 @@ video {
border-bottom-width: calc(1px * var(--tw-divide-y-reverse)); border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
} }
.divide-gray-100 > :not([hidden]) ~ :not([hidden]) {
--tw-divide-opacity: 1;
border-color: rgb(243 244 246 / var(--tw-divide-opacity, 1));
}
.divide-gray-200 > :not([hidden]) ~ :not([hidden]) { .divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
--tw-divide-opacity: 1; --tw-divide-opacity: 1;
border-color: rgb(229 231 235 / var(--tw-divide-opacity, 1)); border-color: rgb(229 231 235 / var(--tw-divide-opacity, 1));
@@ -997,14 +896,6 @@ video {
overflow-x: auto; overflow-x: auto;
} }
.overflow-y-auto {
overflow-y: auto;
}
.overflow-x-hidden {
overflow-x: hidden;
}
.whitespace-nowrap { .whitespace-nowrap {
white-space: nowrap; white-space: nowrap;
} }
@@ -1033,26 +924,11 @@ video {
border-radius: 0.375rem; border-radius: 0.375rem;
} }
.rounded-e-lg {
border-start-end-radius: 0.5rem;
border-end-end-radius: 0.5rem;
}
.rounded-l-md { .rounded-l-md {
border-top-left-radius: 0.375rem; border-top-left-radius: 0.375rem;
border-bottom-left-radius: 0.375rem; border-bottom-left-radius: 0.375rem;
} }
.rounded-s-lg {
border-start-start-radius: 0.5rem;
border-end-start-radius: 0.5rem;
}
.rounded-t {
border-top-left-radius: 0.25rem;
border-top-right-radius: 0.25rem;
}
.border { .border {
border-width: 1px; border-width: 1px;
} }
@@ -1065,10 +941,6 @@ video {
border-bottom-width: 1px; border-bottom-width: 1px;
} }
.border-s-0 {
border-inline-start-width: 0px;
}
.border-t { .border-t {
border-top-width: 1px; border-top-width: 1px;
} }
@@ -1147,10 +1019,6 @@ video {
background-color: rgb(127 29 29 / var(--tw-bg-opacity, 1)); background-color: rgb(127 29 29 / var(--tw-bg-opacity, 1));
} }
.bg-transparent {
background-color: transparent;
}
.bg-white { .bg-white {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1)); background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
@@ -1270,10 +1138,6 @@ video {
padding-top: 0.5rem; padding-top: 0.5rem;
} }
.pt-4 {
padding-top: 1rem;
}
.pt-5 { .pt-5 {
padding-top: 1.25rem; padding-top: 1.25rem;
} }
@@ -1387,11 +1251,6 @@ video {
color: rgb(209 213 219 / var(--tw-text-opacity, 1)); color: rgb(209 213 219 / var(--tw-text-opacity, 1));
} }
.text-gray-400 {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity, 1));
}
.text-gray-500 { .text-gray-500 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity, 1)); color: rgb(107 114 128 / var(--tw-text-opacity, 1));
@@ -1451,16 +1310,6 @@ video {
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.opacity-0 {
opacity: 0;
}
.shadow {
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.shadow-sm { .shadow-sm {
--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color); --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
@@ -1488,26 +1337,12 @@ video {
outline-color: #d1d5db; outline-color: #d1d5db;
} }
.filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
.transition-all { .transition-all {
transition-property: all; transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms; transition-duration: 150ms;
} }
.transition-opacity {
transition-property: opacity;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
}
.duration-300 {
transition-duration: 300ms;
}
.duration-500 { .duration-500 {
transition-duration: 500ms; transition-duration: 500ms;
} }
@@ -1565,11 +1400,6 @@ video {
background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1)); background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
} }
.hover\:bg-gray-200:hover {
--tw-bg-opacity: 1;
background-color: rgb(229 231 235 / var(--tw-bg-opacity, 1));
}
.hover\:bg-gray-400:hover { .hover\:bg-gray-400:hover {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(156 163 175 / var(--tw-bg-opacity, 1)); background-color: rgb(156 163 175 / var(--tw-bg-opacity, 1));
@@ -1610,11 +1440,6 @@ video {
background-color: rgb(127 29 29 / var(--tw-bg-opacity, 1)); background-color: rgb(127 29 29 / var(--tw-bg-opacity, 1));
} }
.hover\:text-gray-900:hover {
--tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity, 1));
}
.hover\:text-indigo-500:hover { .hover\:text-indigo-500:hover {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(99 102 241 / var(--tw-text-opacity, 1)); color: rgb(99 102 241 / var(--tw-text-opacity, 1));
@@ -1762,10 +1587,6 @@ video {
inset: auto; inset: auto;
} }
.sm\:col-span-2 {
grid-column: span 2 / span 2;
}
.sm\:mx-auto { .sm\:mx-auto {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@@ -1775,10 +1596,6 @@ video {
margin-left: 1.5rem; margin-left: 1.5rem;
} }
.sm\:mt-0 {
margin-top: 0px;
}
.sm\:mt-8 { .sm\:mt-8 {
margin-top: 2rem; margin-top: 2rem;
} }
@@ -1842,10 +1659,6 @@ video {
} }
@media (min-width: 768px) { @media (min-width: 768px) {
.md\:inset-0 {
inset: 0px;
}
.md\:flex-1 { .md\:flex-1 {
flex: 1 1 0%; flex: 1 1 0%;
} }
@@ -1862,10 +1675,6 @@ video {
align-items: center; align-items: center;
} }
.md\:p-5 {
padding: 1.25rem;
}
.md\:px-5 { .md\:px-5 {
padding-left: 1.25rem; padding-left: 1.25rem;
padding-right: 1.25rem; padding-right: 1.25rem;
@@ -1875,10 +1684,6 @@ video {
padding-top: 4rem; padding-top: 4rem;
padding-bottom: 4rem; padding-bottom: 4rem;
} }
.md\:pt-5 {
padding-top: 1.25rem;
}
} }
@media (min-width: 1024px) { @media (min-width: 1024px) {
@@ -1952,10 +1757,6 @@ video {
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
.dark\:block {
display: block;
}
.dark\:hidden { .dark\:hidden {
display: none; display: none;
} }
@@ -1980,11 +1781,6 @@ video {
border-color: rgb(31 41 55 / var(--tw-border-opacity, 1)); border-color: rgb(31 41 55 / var(--tw-border-opacity, 1));
} }
.dark\:border-s-gray-700 {
--tw-border-opacity: 1;
border-inline-start-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
}
.dark\:bg-gray-600 { .dark\:bg-gray-600 {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(75 85 99 / var(--tw-bg-opacity, 1)); background-color: rgb(75 85 99 / var(--tw-bg-opacity, 1));
@@ -2010,11 +1806,6 @@ video {
background-color: rgb(220 38 38 / var(--tw-bg-opacity, 1)); background-color: rgb(220 38 38 / var(--tw-bg-opacity, 1));
} }
.dark\:text-gray-200 {
--tw-text-opacity: 1;
color: rgb(229 231 235 / var(--tw-text-opacity, 1));
}
.dark\:text-gray-300 { .dark\:text-gray-300 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(209 213 219 / var(--tw-text-opacity, 1)); color: rgb(209 213 219 / var(--tw-text-opacity, 1));
@@ -2025,11 +1816,6 @@ video {
color: rgb(156 163 175 / var(--tw-text-opacity, 1)); color: rgb(156 163 175 / var(--tw-text-opacity, 1));
} }
.dark\:text-gray-500 {
--tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity, 1));
}
.dark\:text-gray-900 { .dark\:text-gray-900 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity, 1)); color: rgb(17 24 39 / var(--tw-text-opacity, 1));
@@ -2054,16 +1840,6 @@ video {
--tw-ring-offset-color: #1f2937; --tw-ring-offset-color: #1f2937;
} }
.dark\:placeholder\:text-gray-400::-moz-placeholder {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity, 1));
}
.dark\:placeholder\:text-gray-400::placeholder {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity, 1));
}
.dark\:hover\:bg-gray-600:hover { .dark\:hover\:bg-gray-600:hover {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(75 85 99 / var(--tw-bg-opacity, 1)); background-color: rgb(75 85 99 / var(--tw-bg-opacity, 1));

View File

@@ -1,37 +1,36 @@
package main package main
import ( import (
"fmt" "fmt"
"net/http" "io/ioutil"
"io/ioutil" "net/http"
) )
func main() { func testFunc() {
url := "http://localhost:8080/test" url := "http://localhost:8080/test"
method := "GET" method := "GET"
client := &http.Client { client := &http.Client{}
} req, err := http.NewRequest(method, url, nil)
req, err := http.NewRequest(method, url, nil)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
req.Header.Add("Authorization", "Basic dXNlcjpwYXNzd29yZA==") req.Header.Add("Authorization", "Basic dXNlcjpwYXNzd29yZA==")
res, err := client.Do(req) res, err := client.Do(req)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
defer res.Body.Close() defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body) body, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println(string(body)) fmt.Println(string(body))
} }

View File

@@ -81,7 +81,7 @@
<div class="gap-4 sm:flex sm:items-center"> <div class="gap-4 sm:flex sm:items-center">
<button type="button" class="w-full rounded-lg border border-gray-200 bg-white px-5 py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700"><a href="/">Return to Shopping</a></button> <button type="button" class="w-full rounded-lg border border-gray-200 bg-white px-5 py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700"><a href="/">Return to Shopping</a></button>
<button type="submit" class="w-full rounded-lg border border-gray-200 bg-white px-5 py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700">Place binding order</button> <button type="submit" class="w-full bg-gray-900 dark:bg-gray-600 rounded-lg border border-gray-200 bg-white px-5 py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700">Place binding order</button>
</div> </div>
</div> </div>
</div> </div>