Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kerwanp/goland
Just some experimentations in Golang
https://github.com/kerwanp/goland
Last synced: 11 days ago
JSON representation
Just some experimentations in Golang
- Host: GitHub
- URL: https://github.com/kerwanp/goland
- Owner: kerwanp
- Created: 2024-02-13T22:07:46.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-18T00:51:03.000Z (9 months ago)
- Last Synced: 2024-06-21T00:00:57.343Z (5 months ago)
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Test
```go
func DeleteUser(id int, user User, body DeleteUserBody, userRepository UserRepository, r golang.Request) (golang.Response, error) {
err := userRepository.Delete(id)
if err != nil {
return err // Throw 500 (with error message if enabled)
}return golang.Success("User successfully deleted")
}func AuthMiddleware(r goland.Request, auth AuthService, container Container) (goland.Request, error) {
authHeader := r.Headers().Get("Authorization")user := auth.Authorize(authHeader)
if user != nil {
container.Provide(di.T[User], user)
return r
}return nil, MyError
}func main() {
userRouter := golang.NewRouter().
Middleware(AuthMiddleware).
Get("/", GetUsers).
Post("/", CreateUser).
Delete("/{id}", DeleteUser).
Route(nil, "/", PatchUser)app := golang.NewRouter().
Service(di.T[UserRepository], NewUserRepository)
Service(di.T[AuthService], NewAuthService)
Router("/users", userRouter)
}
```- Path patterns
- Routing system (with subrouting)
- Autowiring
- Services
- Request extraction (query params, body, etc)
- User friendly response system
- User friendly request system
- Middleware system
- Error handling system