Skip to main content

Examples

Kratos provides a wealth of sample code/projects for reference

Components' Usage

All Examples

Configuration

  • config example of using config to parse configuration files
  • apollo exmaple of getting configuration from apollo

Service Discovery and Registration

  • etcd example of service registration on the server side and service registration on the client side using the etcd plug-in.
  • nacos example of service registration on the server side and service registration on the client side using the nacos plug-in.
  • consul example of service registration on the server side and service registration on the client side using the consul plug-in.
  • zookeeper example of service registration on the server side and service registration on the client side using the zookeeper plug-in.

HTTP

  • cors example of cross-domain settings
  • gin example of use gin as the router.
  • mux example of use mux as the router.
  • echo example of use echo as the router.
  • static example of static files serving.
  • upload example of file upload.
  • redirect example of redirect.
  • middleware example of use middleware in the router.
  • errors example of error response using unified error handling.

RPC

  • helloworld example of remote calls using http and gRPC.

Trace

  • traces example of use jaeger for tracing.

WebSocket

  • ws example of file WebSocket.

Authentication

  • jwt emxaple of use JWT authentication in HTTP, gRPC.

Log

  • zap example of use Zap.
  • logrus example of use logrus.

Other

  • i18n example of internationalization support.
  • header example of header.
  • selector example of Selector. Selection by Load Balancing and Filter
  • swagger example of use Swagger automaticlly genereate interface documentation and provide online services.

Complete Projects

  • blog a simple CRUD project which includes MySQL Redis integration.

  • beer-shop an online shop application, mono-repo microservices demo for kratos.