Example #1
0
func (this *StaticController) Get() error {
	uS := this.R.URL.String()[1:] // remove fst "/"
	ext := path.Ext(uS)

	var buf []byte
	var cType string

	if mimeType, has := extMimeMap[ext]; has {
		cType = mimeType
		content := text.ProvideString(uS)
		if content == "" {
			return app.ErrNotFound
		}
		buf = []byte(content)

	} else { // is not textual file
		buf = text.ProvideBytes(uS)
		if buf == nil {
			return app.ErrNotFound
		}
	}

	this.W.Header().Set("Content-Type", cType)
	this.W.Write(buf)
	return nil
}
Example #2
0
func (this *IndexController) indexPage() (err error) {
	_, err = io.WriteString(this.W, text.ProvideString("view/index.html"))
	return
}