Skip to content

Releases: go-spring-projects/go-spring

v1.3.0

14 Dec 08:35
164ecd1
Compare
Choose a tag to compare

New mod path

We are excited to announce the latest release of go-spring, now available at its new module path go-spring.dev/spring .

go get go-spring.dev/spring@latest

This release introduces an exciting new feature: support for RouterGroup in web package.

import "go-spring.dev/spring/web"

func main() {
	webSvr := web.NewServer(web.Options{Addr: ":8080"})
	webSvr.Get("/greeting", Greeting)
	webSvr.Post("/feedback", Feedback)

	userGroup := webSvr.Group("/user")
	{
		userGroup.Get("/{user}/info", GetUserInfo)
		userGroup.Post("/{user}/changePassword", UpdatePassword)
		userGroup.Post("/{user}/updateAvatar", UpdateAvatar)
	}

	webSvr.Run()
}

What's Changed

Full Changelog: v1.2.0...v1.3.0

v1.2.0

07 Dec 03:19
8eebf1b
Compare
Choose a tag to compare

New web development experience

We are excited to announce the addition of a brand new Web package to go-spring framework. This package provides developers with a simple, flexible, and powerful way to build web applications.

# http server config
http:
  # listen address
  addr: ":8080"
package main

import (
	"context"
	"log/slog"

	"github.com/go-spring-projects/go-spring/gs"
	"github.com/go-spring-projects/go-spring/web"
	_ "github.com/go-spring-projects/go-spring/web/starter"
)

type Greeting struct {
	Logger *slog.Logger `logger:""`
	Server *web.Server  `autowire:""`
}

func (g *Greeting) OnInit(ctx context.Context) error {
	g.Server.Get("/greeting", g.Greeting)
	g.Server.Post("/feedback", g.Feedback)
	return nil
}

func (g *Greeting) Greeting(ctx context.Context) string {
	return "Greeting!!!"
}

func (g *Greeting) Feedback(
	ctx context.Context,
	req struct {
		Title     string `form:"title"`
		Message   string `form:"message"`
		EMail     string `form:"email"`
		UserAgent string `header:"User-Agent"`
	},
) string {
	g.Logger.Info("received user feedback",
		slog.String("title", req.Title),
		slog.String("message", req.Message),
		slog.String("email", req.EMail),
		slog.String("user-Agent", req.UserAgent),
	)
	//TODO: save feedback to database.
	//
	return "Thanks for your feedback!!!"
}

func main() {
	gs.Object(new(Greeting))

	if err := gs.Run(); nil != err {
		panic(err)
	}
}

What's Changed

  • Add web package for web applications support by @limpo1989 in #9
  • Fix method bean parent resolve incorrect by @limpo1989 in #10
  • Refactor web.Renderer interface by @limpo1989 in #11
  • Add server route method Get/Head/Post/Put/Patch/Delete/Connect/Options/Trace by @limpo1989 in #12
  • Ignore non-existent parameters when binding parameters by @limpo1989 in #13

Full Changelog: v1.1.1...v1.2.0

v1.1.1

15 Nov 08:44
7fee3a7
Compare
Choose a tag to compare

What's Changed

  • Fix circular dependency errors caused by dependencies by @limpo1989 in #7
  • Fix the panic caused by the closure bean by @limpo1989 in #8

Full Changelog: v1.1.0...v1.1.1

v1.1.0

10 Nov 09:50
2dd2233
Compare
Choose a tag to compare

BREAKING CHANGES

This is a breaking change version where we have redesigned the BeanInit/AppEvent interface to decouple the business code from Go-Spring, thereby removing the coupling between the business code and Go-Spring.

type MyApp struct {}

// You need to modify the type gs.Context to context.Context.
func(m *MyApp) OnInit(ctx /* gs.Context ->*/ context.Context) error {
  // use gs.FromContext(ctx) to get gs.Context
  return nil
}

// You need to modify the type gs.Context to context.Context.
func(m *MyApp) OnAppStart(ctx /* gs.Context ->*/ context.Context) {
  // use gs.FromContext(ctx) to get gs.Context
}

func(m *MyApp) OnAppStop(ctx context.Context) {
}

What's Changed

  • Add README_CN.md by @limpo1989 in #1
  • Fixed an dead-loop of value binding when struct slices have default values by @limpo1989 in #2
  • Automatically decide whether to clean the container by @limpo1989 in #3
  • Redesign the BeanInit interface to get away from Go-Spring dependence by @limpo1989 in #4
  • Update README.md by @limpo1989 in #5
  • Redesign the AppEvent interface to get away from Go-Spring dependence by @limpo1989 in #6

New Contributors

Full Changelog: v1.0.0...v1.1.0

v1.0.0

27 Oct 11:06
Compare
Choose a tag to compare

We are excited to announce the first release of a new framework inspired by Java's Spring, designed specifically for Golang - Go-Spring v1.0.0. This version is committed to making the development and management of Golang projects more effortless and introduces a suite of powerful features.

Features

  • IoC Container: Implements an inversion of control (IoC) container based on reflection, supporting the injection of structs, functions, and constants. This means you can use the autowired tag to automatically inject dependencies without having to manage them manually.
  • Flexible Configuration Management: Taking inspiration from Spring's @value annotation, Go-Spring allows you to fetch configuration items from multiple sources (such as environment variables, files, command-line arguments, etc.). This brings unprecedented flexibility in configuration management.
  • Validator Extension for Configuration: Extends its robust configuration management capabilities with support for custom validator extensions. This enables you to perform validity checks on properties, ensuring only valid configurations are applied to your application.
  • Logger Based on Standard slog: Provides built-in logger support using the standard library slog for effective and streamlined logging. This enhancement offers clear, concise, and well-structured logging information that aids in system debugging and performance monitoring.
  • Dynamic Property Refreshing: Provides dynamic property refreshing which lets you update the application properties on-the-fly without needing to reboot your application. It caters to the needs of applications that require high availability and real-time responsiveness.
  • Dependency Ordered Application Events: Ensures the correct notification of initialization and destruction events according to the lifecycle of objects, following the order of bean dependencies. This enhances the robustness and reliability of the system during its lifecycle operations.

Finally, we would like to extend our deepest gratitude to the original initiator of the project, lvan100. His passion, dedication, and innovative ideas laid the solid foundation upon which Go-Spring is built. This milestone would not have been possible without his significant contributions.

We appreciate your support for Go-Spring and welcome feedback and suggestions!