Giter VIP home page Giter VIP logo

gig's People

Contributors

alyssarosenzweig avatar krixano avatar pitr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gig's Issues

Virtual hosting

It doesn't look like there's any way to specify a domain name when running Gig, it'd be nice to be able to do that. And then to have multi-host support, so certain paths can apply only to one host, while other paths do the other. Similar to CompositeApplication in Jetforce.

Reverse-proxying

Feature request.

Gig looks great, nice work! I was wondering if reverse-proxying is on your roadmap, so all requests under a certain route or whatever is sent to a different Gemini server.

"Serving static files" not working as advertised

Issue Description

The following method of serving static file

g.Static("/test.txt", "content/test.txt")

does not seem to work.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

Server running on localhost. When client requests gemini://localhost/test.txt, the server shall return the content of the text file located at content/test.txt. The directory structure used is as follows:

--$GOPATH (dir)
       |--src (dir)
             |--gig_server (dir)
                    |--content (dir)
                    |       |--test.txt
                    |       |--imgs (dir)
                    |                 |--tuxedo_cat.jpg
                    |--main.go
                    |--go.mod
                    |--gig_server (executable)
                    |--my.crt
                    |--my.key

Actual behaviour

The server returns "not found", and logs the following

time="2021-06-18T06:09:03+00:00" path=/test.txt status=51 duration=0.06 error=Not Found

Steps to reproduce

As described above.

Working code to debug

content of main.go:

package main

import "github.com/pitr/gig"

func main() {
        g := gig.Default()

        g.Static("/test.txt", "content/test.txt")

        g.Run("my.crt", "my.key")
}

content of test.txt:

Come find me!

Version/commit

go version go1.16.5 darwin/amd64.
gig version 0.9.8

Note:

When the "static file" designated is a directory, it works fine. e.g.,

g.Static("/imgs", "content/imgs")

works when client requests gemini://localhost/imgs/tuxedo_cat.jpg.

Subdomains issue

Issue Description

In the README you have an example about how to handle subdomains.

g.Handle("/*", func(c gig.Context) error {
      app := apps[c.URL().Host]

      if app == nil {
          return gig.ErrNotFound
      } else {
          return app.ServeGemini(c)
      }
  })

The issue is, that app.ServeGemini doesn't return anything, so this code will not compile.
Also, when app.ServeGemini(c) is run and Handle just does a return nil it will lead to a Stack overflow error if a URL is requested where no handler is registered for.

[gig-debug] ⇨ gemini server started on [::]:1965
time="2021-02-12T12:24:28+01:00" path=/ status=20 duration=0.03 
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc022960430 stack=[0xc022960000, 0xc042960000]
fatal error: stack overflow

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

I think that there should be a separate function which is used to forward requests and which returns an error object which can be used by gig.HandleFunc.

Actual behaviour

See above.

Steps to reproduce

	g.Handle("/*", func(c gig.Context) error {
		app := apps[c.URL().Host]

		if app == nil {
			return gig.ErrNotFound
		}

		app.ServeGemini(c)
		return nil
	})

Then make a request to a valid hostname but a URL without a handler.

Working code to debug

func main() {
	apps := map[string]*gig.Gig{}

	// gemini.tunerapp.org
	tu := tunerapp.App(true)
	apps["gemini.tunerapp.org"] = tu

	pa := paste.App()
	apps["localhost"] = pa

	g := gig.New()
	g.Renderer = &templatesType{
		templates: template.Must(template.New("index").Funcs(helpers).ParseGlob("templates/*.tmpl")),
	}
	g.Handle("/*", func(c gig.Context) error {
		app := apps[c.URL().Host]

		if app == nil {
			return gig.ErrNotFound
		}

		app.ServeGemini(c)
		return nil
	})

	log.Fatal(g.Run("cert.pem", "key.rsa"))
}

Version/commit

github.com/pitr/gig v0.9.7

Basic Titan Support

It'd be cool to have basic Titan support. Titan is a complementary protocol to gemini that allows for upload only.

It uses the same port as gemini, but URLs use the "titan://" scheme. The URLs consist of a path with parameters delimited by semicolons (;), with 3 different parameters, an optional token (kinda like a password, not used for authorization, but rather to prevent bots and spam), a requied size (in bytes) of file to be uploaded, and a required mime parameter (mimetype). After that, then there's a \r\n, followed by the data of the given size.

It also supports Client Certificates.

If the given data is of the wrong size, "59 Meta text" is sent. Otherwise, nothing is sent back, afaik (I could be wrong about this).

Here's the main page for the protocol: https://communitywiki.org/wiki/Titan
You can see a server implementation here: https://alexschroeder.ch/cgit/phoebe/tree/script/phoebe
And for the client: https://alexschroeder.ch/cgit/phoebe/tree/script/titan

Even just some way to hook into Gig to just get all requests that use the titan:// scheme and do my own stuff would be useful. But, if it used some of Gig's features, like routes, that would be cool too :)

Why is context.Context not used?

Issue Description

Context interface Set function signature is

Set(key string, val interface{})

that signature is not safe for client level code to use.

For example, library uses keyword "subject" and this keyword will collide if client level code will use "subject" as well.

Standard GO context will not suffer from this issue if used correctly, because context.WithValue uses interface for the key.

The proper use is demonstrated here: https://stackoverflow.com/questions/39946583/how-to-pass-context-in-golang-request-to-middleware.

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.