Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

⚡️ Robust Web Framework to build Go Services

License

NotificationsYou must be signed in to change notification settings

gebes/there

Repository files navigation

Gopher There

Effortless Go Routing: Build Powerful Services with Minimal Overhead

Made with GoGo VersionDocumentationGoDocGoReportCardLicenseLatest release

🔥 Get Started

🔨 Create a Project

  1. Ensure you haveGo installed.
  2. Create a project withgo mod init github.com/{user}/{repository}
  3. Installthere with thego get command
go get -u github.com/gebes/there/v2
  1. Create amain.go file
package mainimport ("github.com/gebes/there/v2""github.com/gebes/there/v2/status""log")funcmain() {router:=there.NewRouter()router.Get("/",func(request there.Request) there.Response {returnthere.Json(status.OK,map[string]string{"message":"Hello World!",})})err:=router.Listen(8080)iferr!=nil {log.Fatalln(err)}}

📚 Check the Documentation for more info

🚀 Introducingthere - Simplify Your Go Routing

Welcome tothere, a Go routing library designed to streamline your project's API development. By wrapping the defaulthttp mux,there enhances control flow without stripping away the flexibility and power of standard HTTP capabilities.

Why Choosethere?

Developing robust APIs doesn't have to be complicated or time-consuming. Withthere, you can manage response handlingintuitively and efficiently, avoiding the common pitfalls and verbosity typical of many routing frameworks.

  • Error Handling Simplified: Encounter an error? Respond withreturn Error(status, err).
  • Effortless Data Response: Need to send data? Usereturn Json(status, data).
  • Optimize Large Data Transfers: Have large data? Compress easily withreturn Gzip(Json(status, data)).

This approach ensures your code is cleaner, more readable, and maintains full HTTP functionality.

⭐️ Key Features

Minimalistic Control Flow

Enjoy simple and clear control flow in your routes with out-of-the-box handlers that make coding a breeze:

funcCreatePost(request there.Request) there.Response {varbodyPosterr:=request.Body.BindJson(&body)iferr!=nil {returnthere.Error(status.BadRequest,"could not parse body: "+err.Error())    }ifpostById(body.Id)!=nil {returnthere.Error(status.Conflict,"post with this ID already exists")    }posts=append(posts,body)returnthere.Json(status.Created,body)}

🧑‍💻 View full code example

Straightforward Routing

there makes routing straightforward. Define routes and methods easily with groupings and middleware support:

router:=there.NewRouter()router.Group("/user")    .Get("/",Handler)    .Post("/",Handler)    .Patch("/",Handler)router.Group("/user/post")    .Get("/{id}",Handler)    .Post("/",Handler)router.Get("/details",Handler)

🧑‍💻 View full code example and best practices

Expandable - Customize Your Control Flow

Easily extendthere by adding your own responses like a Msgpack response, without the need for third-partydependencies:

import ("github.com/gebes/there/v2""github.com/vmihailenco/msgpack/v5")funcMsgpack(codeint,datainterface{}) there.Response {msgpackData,err:=msgpack.Marshal(data)iferr!=nil {panic(err)    }returnthere.WithHeaders(map[string]string{there.ResponseHeaderContentType:"application/x-msgpack",    },there.Bytes(code,msgpackData))}

🧑‍💻 View full code example

🌟 Additional Features for the Skeptical Gophers

Complete Middleware Support

Utilize existing middleware with minimal changes or create specific middleware for individual routes, enhancingflexibility and control over the request/response lifecycle.

Lightweight - No Dependencies

there is designed to be dependency-free, ensuring a lightweight integration into your projects without bloating yourapplication.

Robust and Tested

With nearly complete test coverage,there is proven in production environments, offering reliability and stability foryour critical applications.

Easy Integration with Existing Code

Thanks tothere's compatibility and flexible architecture, integrating with existing Go codebases and middleware isseamless and straightforward.

Performance

there is as efficient as it gets—built on the default http mux, it matches routes without any performance overhead.Just focus on building your application;there handles the rest.

Check out our benchmarks for more details:

👨‍💻 Contributions

Feel free to contribute to this project in any way! May it be a simple issue, idea or a finished pull request. Everyhelpful hand is welcomed.

Maintained?Maintainer

About

⚡️ Robust Web Framework to build Go Services

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp