lena

joined 6 months ago
MODERATOR OF
[โ€“] lena@gregtech.eu 4 points 7 hours ago (1 children)

Jerk, I'd say, though that would be shaking shaking my head, not shaking my head my head

[โ€“] lena@gregtech.eu 20 points 7 hours ago (3 children)

I'd shake hands with fascists

[โ€“] lena@gregtech.eu 3 points 7 hours ago (3 children)
[โ€“] lena@gregtech.eu 4 points 8 hours ago

Their CI/CD minutes are very generous (unlimited!). Plus, if Microsoft wanted to scrape code, it doesn't have to be on Github. They can scrape it off codeberg too. And I can be sure Github won't shut down.

If Github does decide to screw users over, switching to self-hosted forgejo would be trivial.

[โ€“] lena@gregtech.eu 2 points 8 hours ago (1 children)

Well it says 27 >:(

[โ€“] lena@gregtech.eu 6 points 9 hours ago

Gotta flex those pecs

[โ€“] lena@gregtech.eu 5 points 11 hours ago

Yeah, I always make sure to use the relevant code in my projects. I've been using 422 a lot for missing data.

[โ€“] lena@gregtech.eu 9 points 14 hours ago

Slovenia mentioned ๐Ÿ‡ธ๐Ÿ‡ฎ๐Ÿ‡ธ๐Ÿ‡ฎ๐Ÿ‡ธ๐Ÿ‡ฎ

Based Robert Golob

74
HTTP Cats (http.cat)
 

cross-posted from: https://gregtech.eu/post/16825706

API for HTTP Cats

 

API for HTTP Cats

[โ€“] lena@gregtech.eu 2 points 18 hours ago

Some people are such pieces of shit, why do they have to ruin matrix for the rest of us

[โ€“] lena@gregtech.eu 4 points 18 hours ago

I have never played the minecraft mod :3

I just didn't check whether something named gregtech exists when registering my domain name

[โ€“] lena@gregtech.eu 7 points 18 hours ago (2 children)

Minecraft, on a server with friends. We still play it

[โ€“] lena@gregtech.eu 7 points 18 hours ago (1 children)

Votes are public on kbin and mbin too. Without even logging in.

Regarding hiding votes from admins, that's impossible without crippling moderation tools and allowing vote spam to happen freely, because admins would not be able to investigate. And that's just not how ActivityPub works. Votes are public.

38
Wat (www.destroyallsoftware.com)
 

This is an amazing explanation of inheritance

 

on the voyager Github

I have to open the 197th one ๐Ÿ˜ญ

 

cross-posted from: https://gregtech.eu/post/16712875

Marshaling the field is fine, so using the tag json:"-" won't work. I could use the UnmarshalJSON method on the struct, but I have no idea how to implement it.

I'd rather not make a duplicate of the struct with that field removed, as it causes quite a bit of code duplication, and it's pretty chaotic.

 

Marshaling the field is fine, so using the tag json:"-" won't work. I could use the UnmarshalJSON method on the struct, but I have no idea how to implement it.

I'd rather not make a duplicate of the struct with that field removed, as it causes quite a bit of code duplication, and it's pretty chaotic.

 

cross-posted from: https://gregtech.eu/post/16416819

Hi, what's the best way for testing a gin route?

I currently have one function where the routes are defined. Here it is:

package router

import (
	"github.com/gin-gonic/gin"
	"github.com/gragorther/epigo/handlers"
	"github.com/gragorther/epigo/middlewares"
)

func Setup(userUserStore handlers.UserUserStore, groupGroupStore handlers.GroupGroupStore, groupAuthStore handlers.GroupAuthStore, messageAuthStore handlers.MessageAuthStore, messageMessageStore handlers.MessageMessageStore, middlewareUserStore middlewares.UserStore) *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.ErrorHandler())

	userHandler := handlers.NewUserHandler(userUserStore)
	authHandler := middlewares.NewAuthMiddleware(middlewareUserStore)
	groupHandler := handlers.NewGroupHandler(groupGroupStore, groupAuthStore)
	messageHandler := handlers.NewMessageHandler(messageMessageStore, messageAuthStore)

	// user stuff
	r.POST("/user/register", userHandler.RegisterUser)
	r.POST("/user/login", userHandler.LoginUser)
	r.GET("/user/profile", authHandler.CheckAuth, userHandler.GetUserProfile)
	r.PUT("/user/setEmailInterval", authHandler.CheckAuth, userHandler.SetEmailInterval)

	// groups
	r.DELETE("/user/groups/delete/:id", authHandler.CheckAuth, groupHandler.DeleteGroup)
	r.POST("/user/groups/add", authHandler.CheckAuth, groupHandler.AddGroup)
	r.GET("/user/groups", authHandler.CheckAuth, groupHandler.ListGroups) // list groups
	r.PATCH("/user/groups/edit/:id", authHandler.CheckAuth, groupHandler.EditGroup)

	// lastMessages
	r.POST("/user/lastMessages/add", authHandler.CheckAuth, messageHandler.AddLastMessage)
	r.GET("/user/lastMessages", authHandler.CheckAuth, messageHandler.ListLastMessages)
	r.PATCH("/user/lastMessages/edit/:id", authHandler.CheckAuth, messageHandler.EditLastMessage)
	r.DELETE("/user/lastMessages/delete/:id", authHandler.CheckAuth, messageHandler.DeleteLastMessage)
	return r
}

so, my question is, how can I test just one route? should I run this function in every test and send a request to a route with httptest? Or should I set up my handlers like it's described at https://gin-gonic.com/en/docs/testing/

(like this)

func postUser(router *gin.Engine) *gin.Engine {
  router.POST("/user/add", func(c *gin.Context) {
    var user User
    c.BindJSON(&user)
    c.JSON(200, user)
  })
  return router
}

let me know if you have any other questions about my code.

It's available on github: https://github.com/gragorther/epigo

 

cross-posted from: https://gregtech.eu/post/16416819

Hi, what's the best way for testing a gin route?

I currently have one function where the routes are defined. Here it is:

package router

import (
	"github.com/gin-gonic/gin"
	"github.com/gragorther/epigo/handlers"
	"github.com/gragorther/epigo/middlewares"
)

func Setup(userUserStore handlers.UserUserStore, groupGroupStore handlers.GroupGroupStore, groupAuthStore handlers.GroupAuthStore, messageAuthStore handlers.MessageAuthStore, messageMessageStore handlers.MessageMessageStore, middlewareUserStore middlewares.UserStore) *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.ErrorHandler())

	userHandler := handlers.NewUserHandler(userUserStore)
	authHandler := middlewares.NewAuthMiddleware(middlewareUserStore)
	groupHandler := handlers.NewGroupHandler(groupGroupStore, groupAuthStore)
	messageHandler := handlers.NewMessageHandler(messageMessageStore, messageAuthStore)

	// user stuff
	r.POST("/user/register", userHandler.RegisterUser)
	r.POST("/user/login", userHandler.LoginUser)
	r.GET("/user/profile", authHandler.CheckAuth, userHandler.GetUserProfile)
	r.PUT("/user/setEmailInterval", authHandler.CheckAuth, userHandler.SetEmailInterval)

	// groups
	r.DELETE("/user/groups/delete/:id", authHandler.CheckAuth, groupHandler.DeleteGroup)
	r.POST("/user/groups/add", authHandler.CheckAuth, groupHandler.AddGroup)
	r.GET("/user/groups", authHandler.CheckAuth, groupHandler.ListGroups) // list groups
	r.PATCH("/user/groups/edit/:id", authHandler.CheckAuth, groupHandler.EditGroup)

	// lastMessages
	r.POST("/user/lastMessages/add", authHandler.CheckAuth, messageHandler.AddLastMessage)
	r.GET("/user/lastMessages", authHandler.CheckAuth, messageHandler.ListLastMessages)
	r.PATCH("/user/lastMessages/edit/:id", authHandler.CheckAuth, messageHandler.EditLastMessage)
	r.DELETE("/user/lastMessages/delete/:id", authHandler.CheckAuth, messageHandler.DeleteLastMessage)
	return r
}

so, my question is, how can I test just one route? should I run this function in every test and send a request to a route with httptest? Or should I set up my handlers like it's described at https://gin-gonic.com/en/docs/testing/

(like this)

func postUser(router *gin.Engine) *gin.Engine {
  router.POST("/user/add", func(c *gin.Context) {
    var user User
    c.BindJSON(&user)
    c.JSON(200, user)
  })
  return router
}

let me know if you have any other questions about my code.

It's available on github: https://github.com/gragorther/epigo

view more: next โ€บ