minimalistic-control-flow

command
v2.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2024 License: MIT Imports: 5 Imported by: 0

README

⭐️ Minimalistic control flow

Controlling your route's flow with There is a delight! It is easy to understand and fast to write.
A HttpResponse is basically a http.Handler. There provides several handlers out of the box!

func CreatePost(request HttpRequest) HttpResponse {
	var body Post
	err := request.Body.BindJson(&body)
	if err != nil {
		return Error(StatusBadRequest, "Could not parse body: "+err.Error())
	}

	post := postById(body.Id)
	if post != nil {
		return Error(StatusConflict, "Post with this ID already exists")
	}

	posts = append(posts, body)
	return Json(StatusCreated, body)
}

This handler uses Error and Json. By returning a HttpResponse, the handler chain will break and There will render the given response.

📚 Documentation

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL