Git Product home page Git Product logo

logging-server's Introduction

Logging and Echo server

This is a simple implementation of logging and echo server written in Go using GinGonic.

I've copied gin.logger middleware to print out some information.

Build and run

Easy run!

go build && ./logging-server -bind 0.0.0.0:8888

By default, if no bind paramenter is provided the server binds to localhost:8080.

Example

curl -vvv -d'{"key":"value","banana":"banana"}' -H 'Content-Type: application/json' localhost:8888/test
* Trying 127.0.0.1:8888...
* Connected to localhost (127.0.0.1) port 8888 (#0)
> POST /test HTTP/1.1
> Host: localhost:8888
> User-Agent: curl/7.87.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 33
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Tue, 31 Jan 2023 10:42:55 GMT
< Content-Length: 43
< 
* Connection #0 to host localhost left intact
"{\"key\":\"value\",\"banana\":\"banana\"}"  

Default:

[GIN] 2023/01/31 - 11:42:55 | 200 |      31.851µs |       127.0.0.1 | POST     "/test"

Custom:

[GIN] 2023/01/31 - 11:42:55 | 200 |      31.851µs |       127.0.0.1 | POST     "/test"
Accept              : */*
Content-Length      : 33
Content-Type        : application/json
User-Agent          : curl/7.87.0

{"key":"value","banana":"banana"}

Helper endpoints

/authenticated

With any http verb chech if "Authorization" header is present. If not lead to a 401.

/status/:code

Send a status code to give it back. Example:

curl  -vvv localhost:8080/status/418
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /status/418 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.87.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 418 I'm a teapot
< Content-Type: application/json; charset=utf-8
< Date: Thu, 23 Feb 2023 11:18:11 GMT
< Content-Length: 2
< 
* Connection #0 to host localhost left intact
""%

logging-server's People

Contributors

grogdunn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.