Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mortar

> DevOps
Open source

Mortar is a GO framework/library for building gRPC (and REST) web services.

677 stars0 likes0 views
WebsiteGitHub

About

Mortar is a GO framework/library for building gRPC (and REST) web services.

Mortar

Mortar is a GO framework/library for building gRPC (and REST) web services. Mortar has out-of-the-box support for configuration, application metrics, logging, tracing, profiling, dependency injection and more. While it comes with predefined defaults, Mortar gives you total control to fully customize it.

Demo

Clone this demo repository to better understand some of Mortar capabilities.

When you done, read the documentation.

Service Template

To help you bootstrap your services with Mortar here you can find a template. Read its README first.

Features

  • Bundled Grpc-Gateway (REST Reverse-Proxy).

  • Dependency Injection using Uber-FX.

  • Pimped *http.Client with interceptors support.

  • Abstract support for Logging, Configuration, Tracing and Monitoring libraries. Use provided wrappers or your own.

    • Jaeger wrapper client for tracing.
    • Prometheus wrapper client for monitoring/metrics.
    • Zerolog wrapper for logging.
    • Viper wrapper for configuration.
  • Internal HTTP Handlers

    • Profiling http://.../debug/pprof
    • Debug http://.../debug/*
    • Configuration http://.../self/config
    • Build Information http://.../self/build
    • Health http://.../health
  • Server/Client Interceptors both for gRPC and HTTP, you can choose which to use and/or add your own.

    Some examples

    • HTTP Headers can be forwarded to next hop, defined by list.
    • HTTP Headers can be included in logs, defined by list.
    • Made available in ctx.Context via gRPC incoming Metadata.
    • Automatic monitoring and tracing (if enabled) for every RPC defined by the API.

...and more.

Telemetry (Everything connected)

  • Logs have Tracing Information traceId=6ff7e7e38d1e86f across services

  • Also visible in Jaeger traceId=6ff7e7e38d1e86f if it's sampled.

Support for *http.Client Interceptors, so you can

  • Add request and response info to Trace

  • Log/Dump requests and/or responses when http request fails.

…
  • Alter requests and/or responses (useful in Tests)

    go
    func(*http.Request, clientInt.HTTPHandler) (*http.Response, error) {
        // special case, don't go anywhere just return the response
        return &http.Response{
            Status:        "200 OK",
            StatusCode:    200,
            Proto:         "HTTP/1.1",
            ProtoMajor:    1,
            ProtoMinor:    1,
            ContentLength: 11,
            Body:          ioutil.NopCloser(strings.NewReader("car painted")),
        }, nil
    }

Monitoring/Metrics support

Export to either Prometheus/Datadog/statsd/etc, it's your choice. Mortar only provides the Interface and also caches the metrics so you don't have to.

go
counter := w.deps.Metrics.WithTags(monitor.Tags{
 "color":   request.GetDesiredColor(),
 "success": fmt.Sprintf("%t", err == nil),
}).Counter("paint_desired_color", "New paint color for car")

counter.Inc()

counter is actually a singleton, uniqueness calculated here

For more information about Mortar Monitoring read here.

Additional Features

  • /debug/pprof and other useful handlers
  • Use config_test.yml during tests to override values in config.yml, it saves time.

There are some features not listed here, please check the Documentation for more.

Documentation

Mortar is not a drop-in replacement.

It's important to read its Documentation first.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Godependency-injectiondifxgolang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理